Skip to content

Instantly share code, notes, and snippets.

@ahwinemman
Created June 1, 2020 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahwinemman/e92055ec17ae57365e47196fd63691ea to your computer and use it in GitHub Desktop.
Save ahwinemman/e92055ec17ae57365e47196fd63691ea to your computer and use it in GitHub Desktop.
package com.javaee.injectprops.configuration;
import com.javaee.injectprops.annotations.IntegerProperty;
import com.javaee.injectprops.annotations.StringProperty;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
@ApplicationScoped
public class PropertyProvider {
@Inject
private ConfigurationManager configurationManager;
@Produces
@IntegerProperty
Integer getIntegerPropertyValue(InjectionPoint ip) {
return configurationManager.getIntegerProperty(ip.getAnnotated().getAnnotation(IntegerProperty.class).value());
}
@Produces
@StringProperty
String getStringPropertyValue(InjectionPoint ip) {
return configurationManager.getStringProperty(ip.getAnnotated().getAnnotation(StringProperty.class).value());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment