Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active December 17, 2015 11:05
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/39e7a6931f2613fe2870 to your computer and use it in GitHub Desktop.
Save abhirockzz/39e7a6931f2613fe2870 to your computer and use it in GitHub Desktop.
Using Dynamic CDI event qualifiers
@Inject
private Event<RequestOutcome> outcomeEvent; //no qualifier specified
public void notify(){
RequestOutcome outcome = outcomeEvent.getOutcome();
Annotation qualifier = null;
//determine event qualifier dynamically
if(outcome == Outcome.APPROVED){
qualifier = new Approved();
}
else if(outcome == Outcome.REJECTED){
qualifier = new Rejected();
}
//fire the (dynamically qualified) event
outcomeEvent.select(qualifier).fire(outcome);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment