Created
July 17, 2013 07:42
-
-
Save Qkyrie/6018530 to your computer and use it in GitHub Desktop.
ConfigValue Producer for automatically injecting configuration strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Produces | |
@ConfigValue("") | |
@Dependent | |
public String configValueProducer(InjectionPoint ip) { | |
// We know this annotation WILL be present as WELD won't call us otherwise, so no null checking is required. | |
ConfigValue configValue = ip.getAnnotated().getAnnotation(ConfigValue.class); | |
// This could potentially return a null, so the function is annotated @Dependent to avoid a WELD error. | |
return props.getProperty(configValue.value()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment