Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes EJB and other Java EE Technologies and the fly likes Singleton using EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Singleton using EJB" Watch "Singleton using EJB" New topic

Singleton using EJB

Anandg Joshi

Joined: Nov 24, 2003
Posts: 2
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
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
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 Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
norman richards
Ranch Hand

Joined: Jul 21, 2003
Posts: 367
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)
I agree. Here's the link:
subject: Singleton using EJB
It's not a secret anymore!