Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active February 4, 2016 13:55
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/750da12586bf9f3a4a76 to your computer and use it in GitHub Desktop.
Save abhirockzz/750da12586bf9f3a4a76 to your computer and use it in GitHub Desktop.
Using CDI freebies...
@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