This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on Singleton Session Bean Initialization 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 "Question on Singleton Session Bean Initialization " Watch "Question on Singleton Session Bean Initialization " New topic
Author

Question on Singleton Session Bean Initialization

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Source: EJB 3.1 Spec.


4.8 Singleton Session Beans

A Singleton session bean is a session bean component that is instantiated once per application. In cases
where the container is distributed over many virtual machines, each application will have one bean
instance of the Singleton for each JVM.


Thus,Each Application has only one instance of Singleton Bean.


4.8.1 Singleton Initialization
In some cases, explicit initialization ordering dependencies exist between multiple Singleton compo-
nents in an application. The DependsOn annotation is used to express these dependencies. A
DependsOn dependency is used in cases where one Singleton must initialize before one or more other
Singletons. The container ensures that all Singleton beans with which a Singleton has a DependsOn
relationship have been initialized before PostConstruct is called.


However,from the above paragraph I understand that "there can be multiple Singleton's".

"The container ensures that all Singleton beans with which a Singleton has a DependsOn relationship have been initialized"

Q1. How is this possible as the topic 4.8 says that "Each Application has only one instance of Singleton Bean." ?

Please advise.


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2007
    
  39

Q1. How is this possible as the topic 4.8 says that "Each Application has only one instance of Singleton Bean." ?

Each Application has only one instance of Singleton Bean of a certain class. There can be many Singletons in an application.

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks Frits.
I understood the statement now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Singleton Session Bean Initialization
 
jQuery in Action, 3rd edition