• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple life-cycle Callback methods per class

 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic