File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes What are Interceptors in context of EJB 3.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "What are Interceptors in context of EJB 3.1 " Watch "What are Interceptors in context of EJB 3.1 " New topic
Author

What are Interceptors in context of EJB 3.1

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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.


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1695
    
  25

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

Joined: May 18, 2010
Posts: 634

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 ?


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What are Interceptors in context of EJB 3.1