aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "singleton " Watch "singleton " New topic
Author

singleton

Raj Joe
Ranch Hand

Joined: Oct 15, 2004
Posts: 41
How are singleton classes managed in a clustered environment
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
With the typical singleton implementations - a static variable holding a reference to The Only Instance - you'd get at least one per JVM, maybe more if the class with the static variable got loaded by multiple ClassLoaders. Usually that's ok. Most of my singletons are read-only caches intended to reduce the number of trips to the database or some remote source and one query per JVM is still much better than one per web page request.

But singleton is a pattern, not an implementation, and it might be life and death critical to you to make one instance per cluster with some kind of inter-server communication. That is pretty difficult, especially if you want any kind of failover, but I've definitely seen it done.
[ October 15, 2004: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: singleton