• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Singleton class creation

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
With plenty of materials around singleton and I guess being the most widely used pattern across all j2ee applications. How do we truly make a class Singleton in distributed architecture.

We have many constraints like cloning , reflection , class loaders , multi threading , double checked locking etc.

Please help out the near to exact way we can have singleton in place.

Thanks,
Avinash
 
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to use singleton objects in Java is making the use of Singleton Session Bean (@Singleton). For you to understand how these issues are resolved, study JEE specification of the life cycle of Singleton Session Bean and hows the server providers have settled in clustered environments.
Best Regards.
 
Avinash Tiwari
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

Please help out with Singleton on non EJB perspective. That would be helpful.

Thanks
Avinash
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joshua Bloch in Effective Java book presents the best approach to build objects singleton using enum. But other restrictions you'll need to manually resolve in your project.
 
Ranch Hand
Posts: 52
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also go through the dzone article on Singleton. Though it does not cover anything on J2ee specifications but it is more related to core Java.
http://java.dzone.com/articles/singleton-design-pattern-%E2%80%93
reply
    Bookmark Topic Watch Topic
  • New Topic