aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes what are the conditions to be followed in creating a singleton class or design? 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 "what are the conditions to be followed in creating a singleton class or design?" Watch "what are the conditions to be followed in creating a singleton class or design?" New topic
Author

what are the conditions to be followed in creating a singleton class or design?

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
what are the conditions to be followed in creating a singleton class or design?
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Singleton is merely a Design Pattern. Implementations can vary greatly, especially among languages.
In Java, a Singleton is typically implemented with a public static method that maintains and returns a single instance of the class. The construction of the class outside this static method is forbidden by setting the acessibility level of the Constructor to private.
Example:

For further information on Singletons, swing by the OO, Patterns, UML and Refactoring Forum where this topic is of frequent discussion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what are the conditions to be followed in creating a singleton class or design?