EJB 3.0 interceptors

An interceptor is a method that is automatically called when the business methods of an Enterprise JavaBeans™ (EJB) are invoked.

You can define interceptors for session or message-driven beans. Business method interceptors can be defined to apply to all business methods of a bean class or to specific business methods only.

You denote interceptor classes using the Interceptor annotation on the bean class, or in the deployment descriptor using the <interceptor> element. Interceptor methods are marked with the AroundInvoke annotation or with the <around-invoke> element of the deployment descriptor. The interceptor methods always follow the pattern Object <method_name> (InvocationContext c) throws Exception.

Interceptors that apply to all session and message-driven beans in an ejb-jar file, known as default interceptors, are defined in the deployment descriptor using the <interceptor-binding> element. Interceptor methods can also be applied to specific methods rather than default to all methods or to specific beans by using the Interceptors annotation.

You can define any number of interceptors for a bean class. They are invoked in the order that they are specified. Interceptors defined in external classes are processed before interceptors defined within a bean class.




Related concepts
Enterprise beans
Related tasks
Developing enterprise beans
Related reference
Enterprise bean development best practices
Reference topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 7:37:48 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v701sca&product=was-nd-mp&topic=rejb_3interceptors
File name: rejb_3interceptors.html