• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are Interceptors in context of EJB 3.1

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading EJB 3.1 specification and came across text containing "Interceptors" eg:

4.3.4 Session Bean Lifecycle Callback Interceptor Methods
The following lifecycle event callbacks are supported for session beans. Lifecycle callback interceptor
methods may be defined directly on the bean class or on a separate interceptor class.


So,I have couple questions on this .They are :

1.What exactly does "Interceptor" mean ?
2.How are Interceptor related to EJB ?
3.Are Life-cycle methods of different types of EJB called as Interceptors ?

Plese provide assistance on the above queries.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Just for curiosity: are you also reading a book aside the specs? Otherwise the specs can be quite tough to read and understand.


1.What exactly does "Interceptor" mean ?
2.How are Interceptor related to EJB ?
3.Are Life-cycle methods of different types of EJB called as Interceptors ?

1) An interceptor gives you the possibility to get "in between" the call to a certain method (just before and just after a call). Interceptors for EJBs are defined in their own specs JSR-318 Interceptors ("Specification"). Interceptors are also described for other EE-components in JSR-299.
2) It is a service of the container where the container will call the interceptor method on any EJB or on specific EJB's. You can for example add logging functionality to all you EJBs without having to interfere with the business logic inside the EJB. Have a look at the example (ch. 4.12) in my notes ScbcdLinks.
3) No. You can intercept a call to a lifecycle method with an interceptor.

Regards,
Frits
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frits,

Thanks for the reply.
I am currently reading only the specs.
However, initially I had started reading through Enterprise JavaBeans 3.1 by O'reilly but it didn't help much.

Can you advise on any other book if possible ?


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic