Showing posts with label interceptors. Show all posts
Showing posts with label interceptors. Show all posts

28 January 2009

EJB3 default interceptors

To apply an interceptor class (auctionsystem.infra.EJBMonitor in this example) to all beans, add to the deployment descriptor (ejb-jar.xml):

<ejb-jar>
  <interceptors>
    <interceptor>
      <interceptor-class>auctionsystem.helper.EJBMonitor</interceptor-class>
    </interceptor>
  </interceptors>
  <assembly-descriptor>
    <interceptor-binding>
      <ejb-name>*</ejb-name>
      <interceptor-class>auctionsystem.helper.EJBMonitor</interceptor-class>
    </interceptor-binding>
  </assembly-descriptor>
</ejb-jar>

The order in which interceptors are called is:
  1. default interceptors
  2. class level interceptors (interceptors on superclasses are called first)
  3. method level interceptors
To overrule calling of interceptors with larger scope use these annotations:
  1. @ExcludeDefaultInterceptors
  2. @ExcludeClassInterceptors
There are similar defaults for JPA, but these don't work currently in glassfish (issue 2821)