import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+import java.sql.DriverManager;
import javax.imageio.ImageIO;
import javax.xml.parsers.DocumentBuilderFactory;
}
/**
- * <code>com.sun.jndi.ldap.LdapPoolManager</code> class spawns a thread when it
- * is initialized if the system property
+ * <code>com.sun.jndi.ldap.LdapPoolManager</code> class spawns a thread when
+ * it is initialized if the system property
* <code>com.sun.jndi.ldap.connect.pool.timeout</code> is greater than 0.
* That thread inherits the context class loader of the current thread, so
* that there may be a web application class loader leak if the web app
public void setLdapPoolProtection(boolean ldapPoolProtection) {
this.ldapPoolProtection = ldapPoolProtection;
}
-
+
+ /**
+ * The first access to {@link DriverManager} will trigger the loading of
+ * all {@link java.sql.Driver}s in the the current class loader. The web
+ * application level memory leak protection can take care of this in most
+ * cases but triggering the loading here has fewer side-effects.
+ */
+ private boolean driverManagerProtection = true;
+ public boolean isDriverManagerProtection() {
+ return driverManagerProtection;
+ }
+ public void setDriverManagerProtection(boolean driverManagerProtection) {
+ this.driverManagerProtection = driverManagerProtection;
+ }
+
@Override
public void lifecycleEvent(LifecycleEvent event) {
// Initialise these classes when Tomcat starts
ClassLoader.getSystemClassLoader());
/*
+ * First call to this loads all drivers in the current class
+ * loader
+ */
+ if (driverManagerProtection) {
+ DriverManager.getDrivers();
+ }
+
+ /*
* Several components end up calling:
* sun.awt.AppContext.getAppContext()
*
is <code>true</code>.</p>
</attribute>
+ <attribute name="driverManagerProtection" required="false">
+ <p>The first use of <code>java.sql.DriverManager</code> will trigger the
+ loading of JDBNC Driver in the the current class loader. The web
+ application level memory leak protection can take care of this in most
+ cases but triggering the loading here has fewer side-effects. The
+ default is <code>true</code></p>
+ </attribute>
+
<attribute name="gcDaemonProtection" required="false">
<p>Enables protection so that calls to
<code>sun.misc.GC.requestLatency(long)</code> triggered by a web