Last active
December 17, 2015 11:05
-
-
Save abhirockzz/39e7a6931f2613fe2870 to your computer and use it in GitHub Desktop.
Using Dynamic CDI event qualifiers
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
@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