venerdì, aprile 20, 2007

singleton for tomcat

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:

gtrev ha detto...

Thank you Enrico! This is a very useful tip!

Anonimo ha detto...

Yeah, very useful!
Tnx