JBoss Community

Intercept SessionSynchronization

created by Moe Pad in EJB3 - View the full discussion

Hi,

 

I try to intercept the methods of javax.ejb.SessionSynchronization with a decorator. My decorator looks like that:

 

@Decoratorpublic abstract class EJBRollbackDecorator implements MyTestBean{
 
  @Inject
  @Delegate
  @Any
  private MyTestBean myTestBean;
 
  ByteArrayOutputStream serializedObject = new ByteArrayOutputStream();
  Logger logger = Logger.getLogger(this.getClass().getName());
 
  public EJBRollbackDecorator() {
  }
 
  @PostConstruct
  public void postConstruct() {
    logger.info("[DECORATOR]: constructed = " + this);
  }
 
  @Override
  public void afterBegin() {
    logger.info("[DECORATOR]: afterBegin");
  }
 
  @Override
  public void afterCompletion(boolean committed) {
    logger.info("[DECORATOR]: afterCompletion");
    
  }
 
  @Override
  public void decoratorTest() {
    logger.info("[DECORATOR]: decoratorTest = " + this);
  }
}

 

Of course, MyTestBean implements SessionSynchronization.

 

When a new transaction is started (or committed) none of the methods of the decorator is called. But if I call the decoratorTest() method of my test bean everything works fine.

 

Is this a bug or are the methods of SessionSynchronization not supposed to be intercepted?

 

Thanks in advance,

Moe

Reply to this message by going to Community

Start a new discussion in EJB3 at Community