File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Singleton Implementation in Distributed Environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Singleton Implementation in Distributed Environment" Watch "Singleton Implementation in Distributed Environment" New topic
Author

Singleton Implementation in Distributed Environment

Vaibhav G Garg
Ranch Hand

Joined: Sep 23, 2011
Posts: 132
We are having a web application deployed on tomcat but now we are going to deploy the same web application on different servers i.e. in clustered environment. We do have some classes implemented as Singleton. So, in clustered environment, the singleton functionality is going to break. Please let me know the feasible solution so that there will be just one instance every time for the object in the clustered environment.
Stevens Miller
Ranch Hand

Joined: Jul 26, 2012
Posts: 377
    
    1

Tell us a bit more about your situation, please. What do the singletons do that require they be singletons? Can you delegate that part to a central server, or would that violate your design requirements (or be too much for a central server to handle)?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

While this is a bit late, you really should not be using Singletons. You have found one of the reasons, in complex environments, you can't be sure that they are really singletons.

Additionally, Singletons are simply global wads of data, which totally breaks encapsulation. This makes unit testing much harder than systems without singletons.

In nearly all cases, the use of Singletons is a mistake and can be avoided simply by deciding not to use them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Singleton Implementation in Distributed Environment
 
Similar Threads
singleton
Doubts in Clustered server environment
clustered environment - Singleton class
Clustered Singleton
How to use Singleton Design pattern in a Clustered Environment?