Please kindly ignore my e-mail. The second I have send it, I discovered that I have 2 copies of XYZFactory jar files (one in common/ lib and one in web-app/WEB-INF/lib). As soon as I nefed web-app version, things work they way they should


On Nov 14, 2007, at 12:36 , Andrei Tchijov wrote:

I am trying to make singleton class (which is essentially factory) available to my valve and my web-app. I thought that all I need to do is to put jar file with this singleton class in common/lib. For some reason it does not work. It looks like my class gets loaded twice (once when servlet from my web-app trying to get this singleton and another time when valve doing it).

I am using tomcat 5.5.25 and I am fairly sure that my singleton code is ok. Just in case it goes like this (and I know that getFactory() is not thread safe, but in my case there is no any risk that this method will be called at the same time from more then one thread)


public class XYZFactory {
        
        private static XYZFactory _singleton = null;

        XYZFactory() {
        }

        public static XYZFactory getFactory() {
                if( _singleton == null ) {
                        _singleton = new XYZFactory();
                }
                return _singleton;
        }

        ...

        public XYZ getXYZ() {
                ...
        }
}


Your thoughts/comments will be highly appreciated.

Andrei

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to