If you want having just one singleton class shared by all the web applications of your tomcat instance, you have to put the jar containing your singleton class in the folder tomcat/shared and don't put it in the WEB-INF/lib folder of your webapp. In this way the instance will be created just once,after the first call to the method MySingleton.getInstance() and it will be a real singleton object shared between all the webapps.
I needed a such behavior because I want to implement a centralized management of rules, using acegi framework in my project.
2 commenti:
Thank you Enrico! This is a very useful tip!
Yeah, very useful!
Tnx
Posta un commento