File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple life-cycle Callback methods per class

 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic