| Author |
Real World Example of Singleton Pattern
|
Vineela Devi
Ranch Hand
Joined: Dec 20, 2003
Posts: 191
|
|
Hi, Can anyone please give me a real world example of using singleton pattern. Regards, Vineela
|
 |
Vinny Menon
Ranch Hand
Joined: Jan 10, 2006
Posts: 62
|
|
Hi Vineela, one real world example would be: in one of my earlier projects,we had used the business delegate design pattern.i.e. we had used struts framework and within the action class ,we made call to the business delegate classand from the business delegate class we made the call to the session bean. we didnt want multiple instances of the business delegate and wanted to control the instance of the Business Delegate.hence we made it a singleton class. the flow is like this.. Jsp-->action class-->Business Delegate(Singleton)-->Session Beans-->entity bean-->Database. hth cheers vinny m
|
Regards,Vinny M.
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
|
 |
Reid M. Pinchback
Ranch Hand
Joined: Jan 25, 2002
Posts: 775
|
|
|
Many services in a J2EE server are arguably instances of the singleton pattern. At any one time only one variation of a specific service will be in use by the server, but different configurations of the server will allow different choices of service. For example, there will only be one global JNDI tree to search (one in the sense that there is a unique root starting point), but the implementation of that JNDI could be something vendor-specific, an external LDAP, Active Directory, etc.
|
Reid - SCJP2 (April 2002)
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
|
I've used them frequently for caches, factories and statistics utilities like a hit counter.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
B.Sathish
Ranch Hand
Joined: Aug 18, 2005
Posts: 372
|
|
|
Thread pools, connection pools, registry objects, objects handling user preferences, caches
|
 |
 |
|
|
subject: Real World Example of Singleton Pattern
|
|
|