Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What can be done in distributed environment for singleton to work?does any orm supports this feature in distributed environment?

user-image
Question added by Kais Hamdulay , Technical Lead , Barclays
Date Posted: 2016/03/10
Mohammad Shahnawaz Akhter Shahnawaz
by Mohammad Shahnawaz Akhter Shahnawaz , Senior Software Engineer. , Bank of America

When an Application is Distributed across multiple JVMS my single ton class will have multiple instances at each JVM. I will have to generate a Unique ID for this purpose i have to use a singleton pattern class. We can use a central place (like database) to generate the ids. Of course you need to do appropriate locking on the resource so that it is modified by only one entity at a time.

Another Solution would be to use Spring GemFire approach or to use Java NIO package for more fine grained approach.

Singleton pattern is a design solution where an application wants to have one and only one instance of any class, in all possible scenarios without any exceptional condition. It has been debated long enough in java community regarding possible approaches to make any class singleton. Still, you will find people not satisfied with any solution you give. They can not be overruled either. In this post, we will discuss some good approaches and will work towards our best possible effort.

More Questions Like This