Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Logging success of transaction from EJB
  2. public class MyEjb {
  3.  
  4.   @Inject
  5.   AnotherEjb anotherEjb;
  6.  
  7.   @Inject
  8.   LoggerEjb logger;
  9.  
  10.   public void doSomeThing() {
  11.      MyBean b = getSomething();
  12.      anotherEjb.persistSg(b);
  13.  
  14.      /* logger.log is transaction if of attrubute NOT_SUPPORTED to
  15.         ensure separation from caller transaction */
  16.      logger.log("Did something successfully.");
  17.   }
  18.  
  19. }
  20.  
  21. public class AnotherEjb {
  22.  
  23.   @Inject
  24.   EntitiyManager em;
  25.  
  26.   public void persistSg(MyBean entity) {
  27.     em.persist(entity);
  28.   }
  29. }