Deprecated: Assigning the return value of new by reference is deprecated in /home/techmasa/public_html/wp-content/plugins/sem-cosmos-link/sem-cosmos-link.php on line 90

Deprecated: Assigning the return value of new by reference is deprecated in /home/techmasa/public_html/wp-content/plugins/sem-recent-posts.php on line 942

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/techmasa/public_html/wp-content/plugins/sem-cosmos-link/sem-cosmos-link.php:90) in /home/techmasa/public_html/wp-content/plugins/wordpress-automatic-upgrade/wordpress-automatic-upgrade.php on line 121

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/techmasa/public_html/wp-content/plugins/sem-cosmos-link/sem-cosmos-link.php:90) in /home/techmasa/public_html/wp-content/plugins/wordpress-automatic-upgrade/wordpress-automatic-upgrade.php on line 121
TechMasala - Technology Spice Rack » 2006 » May » 20

Archive for May 20, 2006

Singleton Pattern and the Class Loader

Singleton pattern is the most simplest and easiest of the design patterns that any designer/developer would be aware of. The purpose of a singleton pattern is to make sure that there is only one instance of an object throughtout the application’s life. Once an instance is created, the design makes it in a way that only that instance is used even if the program tries to create a new instance of it. The singleton object itself is lazily loaded meaning it is loaded only when the first use of the object is encountered. In essence Singleton objects have an application scope.

I was thinking that if I follow the design principles behind the singleton pattern I have a singleton object until I read through the JDC Tech Tips published in January this year. I thought this would be worth mentioning since I mentioned about class loaders few days back. According to the tip, if you are using a singleton pattern in your application and your application is a web application then which class loader in the application server loads the singleton class plays an important role in deciding really whether your class is a singleton or not. If the System class loader loads the singleton class and that instance is shared by all the other class loaders, then it is really a singleton object. If multiple class loaders were able to load the same class, then you dont really have a singleton object. Makes sense to me.


Deprecated: Function ereg_replace() is deprecated in /home/techmasa/public_html/wp-content/plugins/sociable/sociable.php on line 64
Blink this Singleton Pattern and the Class Loader at blinklist.com    Bookmark Singleton Pattern and the Class Loader at blogmarks    Bookmark Singleton Pattern and the Class Loader at del.icio.us    Digg Singleton Pattern and the Class Loader at Digg.com    Fark Singleton Pattern and the Class Loader at Fark.com    Bookmark Singleton Pattern and the Class Loader at Furl.net    Bookmark Singleton Pattern and the Class Loader at NewsVine    Bookmark Singleton Pattern and the Class Loader at reddit.com    Bookmark Singleton Pattern and the Class Loader at Simpy.com    Bookmark Singleton Pattern and the Class Loader at Spurl.net    Bookmark Singleton Pattern and the Class Loader with wists    Bookmark Singleton Pattern and the Class Loader at YahooMyWeb

Comments      Cosmos


Creative Commons License  This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.