• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

A Question about The Life Cycle of a Stateless Session Bean

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As We know the bean class may define one @PostConstruct method,
When the EJB server is first started, it may create a number of stateless bean instances and enter them into the Method-Ready Pool.
My Question is that when I define a PostConstruct method in stateless bean, Does this method is invoked for each instance?
in the other words, If I define PostConstruct method for some global resource initialization which should be executed only once, does container call this mehod by each instance more than once?

after all,How can I define some method for initializing global resource and container just only call once? and How about recycle such resource only when the container is closing.

Thanks!
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kong song wrote:As We know the bean class may define one @PostConstruct method,
When the EJB server is first started, it may create a number of stateless bean instances and enter them into the Method-Ready Pool.
My Question is that when I define a PostConstruct method in stateless bean, Does this method is invoked for each instance?



Yes, @PostConstruct is per instance of the bean.

kong song wrote:
after all,How can I define some method for initializing global resource and container just only call once? and How about recycle such resource only when the container is closing.

Thanks!


Let's continue this second question in your other thread here
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic