• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Singleton Implementation in Distributed Environment

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)?
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic