Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

callback listener class vs callback interceptor class?

 
Helen Ge
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am confused with the ways to implement the lifecycle callback methods. It seems it can be done in 3 ways?

1. directly annotate the callback methods with the callback event annotation such as @postConstruct etc inside the EJB class.

2. map the ejb class with a callback listener class and move the callback method inside the listerner class.


3. map the ejb class with an interceptor class and move the callback method inside the interceptor class.


So, what's the difference between the callback listener and callback interceptor class?

please help me to understand these.

thanks.


Helen Ge

SCJP
SCWCD
SCJWD
 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we create a interceptor on a callback life-cycle it will execute before the method callback in the listener. Then we can decide to proceed with the listener method or not.
 
Helen Ge
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Padro,

Thanks for your explaination.

Did you mean if both callback listener and interceptor classes for the life cycle events are defined, then the interceptor will be first excuted and wether to call the it's proceed() method or not will make the callback listener to be called or skipped?


Is this explained somewhere in the EJB3.0 spec? I might missed that part?


Thanks

Helen Ge

SCJP
SCWCD
SCJWD
 
Pedro Erencia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mean if both callback listener and interceptor classes for the life cycle events are defined, then the interceptor will be first excuted and wether to call the it's proceed() method or not will make the callback listener to be called or skipped?


Exactly



Is this explained somewhere in the EJB3.0 spec? I might missed that part?


I don't know where is it in the spec. I read it recently in EJB3 in Action.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic