aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Multiple life-cycle Callback methods per class 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 "Multiple life-cycle Callback methods per class" Watch "Multiple life-cycle Callback methods per class" New topic
Author

Multiple life-cycle Callback methods per class

Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

It is given in the spec that

At most one method of a given interceptor class can be designated as an around-invoke method, a
pre-construct method, a post-destroy method, a pre-passivate method, or a post-activate method, regardless of whether the deployment descriptor is used to define interceptors or whether some combination of annotations and deployment descriptor elements is used.


I am trying the same. I have defined three @PostConstruct methods in Interceptror class. While running the example, Only one method is executing , but there is no error for specifying more than one method for post-construct callback.

The code for interceptor class is



The output is

In @PostConstruct of Interceptor class 1
In @PostConstruct defined in Bean Class

The second line of output is for the @PostConstruct method defined in bean class itself.

I am not clear, why only one method picked up from Interceptor class and why the second method only.

Please clarify.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
I think what is mentioned in the spec is a standard to be followed by the bean provider. Though if you do not actually follow it, it may not be explicitely throwing an error.


Thanks and Regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple life-cycle Callback methods per class