Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created September 27, 2015 08: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 abhirockzz/ef7fa9505f22d8b013a2 to your computer and use it in GitHub Desktop.
Save abhirockzz/ef7fa9505f22d8b013a2 to your computer and use it in GitHub Desktop.
@Any in action: accessing all possible bean implementations
public class ParsingService{
@Inject
@Any
Instance<Parser> parsers; //javax.enterprise.inject.Instance handles the magic behind the scenes
public void availableParsingOptions(){
for(Parser parser : parsers){
System.out.println("Parser implementation class: "+ parser.getConcreteImplName());
System.out.println("Supported format: "+ parser.getSupportedFormat().getName());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment