Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Interceptors and decorators are applied for business method invocations. For a detailed overview of what a business method invocation is, it's best to consult the JSR-299 specification, more specifically section 7.2.

  • Initializer methods are not intercepted, so an @Inject method will not be intercepted or decorated while the bean is initialized
  • Lifecycle invocations are interceptor calls themselves - so a @PostConstruct/@PreDestroy-annotated method will not be intercepted or decorated by an @AroundInvoke method when invoked by the container.
  • initializers and lifecycle interceptor methods defined on a bean may be intercepted if they are invoked directly by other beans in the application.
  • Other CDI methods such as producers, disposers and observers are intercepted all the time.

Remember that only references provided by the container are intercepted or decorated. This is important when considering self-invocations (calls to this) - these calls are not business method invocations and will not be intercepted and decorated.

To illustrate this concept, assuming that @InterceptMe is an interceptor binding:

class SelfInvokingClass {
   
   @InterceptMe
   public void methodA() {}
	
   @InterceptMe
   public void methodB() { 
      this.methodA() 
   }
	
}

class InvokerClass {

   @Inject SelfInvokingClass dependency;

   public void callMethodA() { 
     dependency.methodA();
   }
	
   public void callMethodB() { 
     dependency.methodB();
   }
}

When calling InvokerClass.callMethodA(), methodA() will be intercepted.

When calling InvokerClass.callMethodB(), methodB() will be intercepted, but methodA() (invoked from within methodB()) won't be.