There are several reasons for avoiding using singletons with j2ee applications. One reason is that at least in theory there could be situations when two or more such singletons could be created in the same JVM if the getInstance method is not properly synchronized (and synchronization is another forbidden word in the j2ee world :-)). Another reason might be that in a clustered environment you�ll have as many singletons as server instances and your application should be designed accordingly. However none of these pitfalls could be a problem for your code. As a matter of fact, I�ve seen a legacy application that uses home factory pattern within Struts action classes and it runs pretty well. It supports more than 3000 concurrent users and was deployed in production more than 3 years ago. If this makes you feel better I�ll tell you that the code they�re using looks pretty similar to the one you�ve posting :-) Regards.
I think, therefore I exist -- Rene Descartes
Joined: Aug 24, 2005
plz let me know the code you are talking about
Joined: Feb 17, 2005
The code is similar to the one posted on sun's site: