This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes @ExcludeClassInterceptors annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "@ExcludeClassInterceptors annotation" Watch "@ExcludeClassInterceptors annotation" New topic

@ExcludeClassInterceptors annotation

Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 951

I have interceptor class. In it one @PostConstruct method is defined. I am attaching this interceptor class to one stateless session bean. In the Stateless session bean there is also one @PostConstruct method is defined.

When executing both the post construct methods are executing. I want to suppress execution of post construct method in interceptor class, so I use @ExcludeClassInterceptors annotation to the PostConstruct method defined in bean class. But still both method are executing.

Is it a right approach ? Is the @ExcludeClassInterceptors applicable to life-cycle methods, or simply ignored ?

The bean class is

and the Interceptor class is


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
The Javadoc defines ExcludeClassInterceptors as "Used to exclude class-level interceptors for a business method."

I ran your example and I think interceptors are ignored for life-cycle methods.

SCJP5 | SCBCD5 | SCEA5 Part 1
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 951

Thank for confirmation. Like to know any other way to exclude life-cycle callback interceptors at class level or application (default) level interceptors.
I agree. Here's the link:
subject: @ExcludeClassInterceptors annotation
It's not a secret anymore!