Created
September 27, 2015 08:47
-
-
Save abhirockzz/ef7fa9505f22d8b013a2 to your computer and use it in GitHub Desktop.
@Any in action: accessing all possible bean implementations
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
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