File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Singleton Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Singleton Pattern" Watch "Singleton Pattern" New topic

Singleton Pattern

Balaji Nagarajan

Joined: Jul 15, 2002
Posts: 4
How do i implement a Singleton in a J2EE application(for server side classes)?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
This is a common question to which there is no standard answer as far as I know. The problem is that the application may reside in a clustered environment made of several JVMs.
Here are some resources related to the subject:
J2EE Singleton pattern at
JBoss clustering / singleton services
J2EE singleton by

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
I agree with Lasse, but if you are in a enviroment with a single JVM, the Singleton Pattern is usefull to make DAO�s (Data Access Objects).

Gustavo Adolpho Bonesso<br />SCJP1.4
I agree. Here's the link:
subject: Singleton Pattern
It's not a secret anymore!