Perhaps, another way to do this is to designate a server within a cluster to host the singleton instance. Other servers contains just a remote proxy which access the singleton on this server. Synchronization is taken care in a single JVM.
Can you describe your requirements a bit more? A lot of times a single instance per JVM is fine. For example, we cache some things we get from the database. Each server has its own cache, no problem.
In one case we have to synchronize the caches so all machines have the same content. The vendor framework uses JMS pub-sub to let all machines know about changes. I gotta ask them some day how they handle a machine that joins the cluster late, like maybe we crash and restart one.
If you really, truly require one instance per cluster you'll have to get into some kind of distributed stuff, worry about a hot standby in case the one machine in the cluster that has the single instance goes away. I'd be tempted to use a database for any state with those requirements.
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'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth