• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singleton using EJB

 
Anandg Joshi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best approach for implementing the Singleton design pattern using EJB and how to log important events from the EJB (The specs prohibits the use of Sockets/File IO)?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the singleton idea, see this article. However, be aware of the limitations of this approach. If you need the singleton value to be clusterable, then you should look at the Distributed Cache approach described in my article in this month's JavaRanch Journal.
Kyle
 
norman richards
Author
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are actually trying to accomplish with the singleton? Do you really need a singleton or are you just trying to apply a "design pattern". I don't know your domain, but based on my experience, I'd say there's a 99% chance you don't actually need the singleton. You'll save yourself a lot of trouble but not chasing after an anti-pattern. Instead, look at the qualities of the singleton you are really interested in (controlled instantiation, caching, etc...) and pick a solution that gives you those. (just a suggestion)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic