What is the difference between Spring Singleton bean scope & Singleton Design pattern? or how are they different ?
Singleton pattern is described at per class loader level.
Singleton bean scope is per spring container. Spring simply creates a new instance of that class and that is available in the container to all class loaders which use that container.
Suppose you have two scenarios:
1. There are multiple class loaders inside the same spring container..
2. There are multiple containers using same class loader..
In first case - you will get 1 instance while in case 2 - you will get multiple instances ...
References:
http://www.techienjoy.com/Spring-Singleton-GOF-Singleton-Difference.php
http://forum.springsource.org/showthread.php?113507-Diff-between-Spring-singleton-and-Singleton-design-pattern
No comments:
Post a Comment