Skip to content

Instantly share code, notes, and snippets.

@Qkyrie
Created July 17, 2013 07:38
Show Gist options
  • Save Qkyrie/6018505 to your computer and use it in GitHub Desktop.
Save Qkyrie/6018505 to your computer and use it in GitHub Desktop.
ConfigValue annotation for automatically injecting configuration strings
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE})
public @interface ConfigValue {
// Excludes this value from being considered for injection point matching
@Nonbinding
// Avoid specifying a default value, since it can encourage programmer error.
// We WANT a value every time.
String value();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment