Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Kais Hamdulay , Technical Lead , Barclays
Date de publication: 2016/03/10
Mohammad Shahnawaz Akhter Shahnawaz
par Mohammad Shahnawaz Akhter Shahnawaz , Checker Module , Addition of Msisdn

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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?