• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 497
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: 497
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic