aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes A Question about The Life Cycle of a Stateless Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "A Question about The Life Cycle of a Stateless Session Bean" Watch "A Question about The Life Cycle of a Stateless Session Bean" New topic
Author

A Question about The Life Cycle of a Stateless Session Bean

kong song
Greenhorn

Joined: May 12, 2009
Posts: 13
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!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

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


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Question about The Life Cycle of a Stateless Session Bean