A
Alexandre Brizard
Hi!
I have a singleton class that operates on a Tomcat server. When I
start Tomcat, everything is fine, I have only one instance of the
class. But, if I modify the web.xml file, per example, and the context
is stopped then restarted, the instance I had in the first place isn't
destroyed and continues to run, and another singleton is created when I
call the getInstance() method of the singleton. How do I fix that?
Here are some excerpts of my class:
public class ConnectionPool {
private static ConnectionPool instance = null;
..
..
..
public synchronized static ConnectionPool getInstance()
throws SQLException, ClassNotFoundException {
if (instance == null){
instance = new
ConnectionPool(m_driverName,m_dbURL,m_user,m_password);
}
return instance;
}
..
..
..
};
Thanks!
I have a singleton class that operates on a Tomcat server. When I
start Tomcat, everything is fine, I have only one instance of the
class. But, if I modify the web.xml file, per example, and the context
is stopped then restarted, the instance I had in the first place isn't
destroyed and continues to run, and another singleton is created when I
call the getInstance() method of the singleton. How do I fix that?
Here are some excerpts of my class:
public class ConnectionPool {
private static ConnectionPool instance = null;
..
..
..
public synchronized static ConnectionPool getInstance()
throws SQLException, ClassNotFoundException {
if (instance == null){
instance = new
ConnectionPool(m_driverName,m_dbURL,m_user,m_password);
}
return instance;
}
..
..
..
};
Thanks!