Last active
February 4, 2016 13:55
-
-
Save abhirockzz/750da12586bf9f3a4a76 to your computer and use it in GitHub Desktop.
Using CDI freebies...
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
@Stateless | |
@TransactionManagement(TransactionManagementType.BEAN) | |
@Path("cdi/freebies") | |
public class CDIFreebieResource { | |
@Inject | |
UserTransaction uTx; | |
@Inject | |
Principal actor; | |
@Inject | |
HttpSession httpSession; | |
@Inject | |
HttpServletRequest httpSR; | |
@Inject | |
ServletContext sCtx; | |
@GET | |
public String get() throws Exception{ | |
return | |
"User Tx status: " + uTx.getStatus() + "\n" + | |
"Principal: " + actor.getName() + "\n" + | |
"HTTP Session ID: " + httpSession.getId() + "\n" + | |
"HTTP Method: " + httpSR.getMethod() + "\n" + | |
"Context Path: " + sCtx.getContextPath(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment