aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes question about interceptor methods invocation order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "question about interceptor methods invocation order" Watch "question about interceptor methods invocation order" New topic
Author

question about interceptor methods invocation order

Mellon Sun
Ranch Hand

Joined: Feb 20, 2003
Posts: 126
If there are two interceptor classes, one is annotated on the bean class and the other is defined via xml descriptor, which one is called first?


SCJP,SCWCD1.3,SCWCD1.4,SCJD,SCBCD5,SCEA5
Mellon Sun
Ranch Hand

Joined: Feb 20, 2003
Posts: 126
I tested that in GlassFish V2 via NetBean6.5.

The annotated one on the class is called prior to the descriptor defined one. And if annotated a interceptor on the class and assembled it via descriptor again, the interceptor's method is called twice.

Does the specification prove this somewhere?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The order of invocation is described in chapter 12 :

12.1 Overview
12.3.1 Multiple Business Method Interceptor Methods
12.4.1 Multiple Callback Interceptor Methods for a Life Cycle Callback Event
12.8.2 Specification of the Binding of Interceptors to Beans

The deployment descriptor may be used to augment the interceptors and interceptor methods defined by means of annotations. When the deployment descriptor is used to augment the interceptors specified in annotations, the interceptor methods specified in the deployment descriptor will be invoked after those specified in annotations, according to the ordering specified in sections 12.3.1 and 12.4.1. The interceptor-order deployment descriptor element may be used to override this ordering.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about interceptor methods invocation order