tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hux...@apache.org
Subject svn commit: r1818927 - in /tomcat/tc7.0.x/trunk: java/org/apache/catalina/loader/WebappClassLoaderBase.java java/org/apache/catalina/loader/WebappLoader.java java/org/apache/catalina/loader/mbeans-descriptors.xml webapps/docs/changelog.xml
Date Thu, 21 Dec 2017 14:07:21 GMT
Author: huxing
Date: Thu Dec 21 14:07:20 2017
New Revision: 1818927

URL: http://svn.apache.org/viewvc?rev=1818927&view=rev
Log:
Support configure the interval to keep all jars open if no jar is accessed.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?rev=1818927&r1=1818926&r2=1818927&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java Thu Dec
21 14:07:20 2017
@@ -371,6 +371,10 @@ public abstract class WebappClassLoaderB
      */
     protected long lastJarAccessed = 0L;
 
+    /**
+     * The interval in milliseconds that we can keep jar files open.
+     */
+    protected int jarOpenInterval = 90000;
 
     /**
      * The list of local repositories, in the order they should be searched
@@ -656,6 +660,20 @@ public abstract class WebappClassLoaderB
 
     }
 
+    /**
+     * Set the interval to keep all jar files open
+     * @param jarOpenInterval the interval in milliseconds to keep jar files open
+     */
+    public void setJarOpenInterval(int jarOpenInterval) {
+        this.jarOpenInterval = jarOpenInterval;
+    }
+
+    /**
+     * Return the interval to keep all jar files open if no jar is accessed
+     */
+    public int getJarOpenInterval() {
+        return jarOpenInterval;
+    }
 
     /**
      * @return Returns the antiJARLocking.
@@ -987,6 +1005,7 @@ public abstract class WebappClassLoaderB
         base.contextName = this.contextName;
         base.hasExternalRepositories = this.hasExternalRepositories;
         base.searchExternalFirst = this.searchExternalFirst;
+        base.jarOpenInterval = this.jarOpenInterval;
     }
 
 
@@ -2174,10 +2193,10 @@ public abstract class WebappClassLoaderB
      * JAR resources.
      */
     public void closeJARs(boolean force) {
-        if (jarFiles.length > 0) {
+        if (jarFiles.length > 0 && (force || jarOpenInterval > 0)) {
                 synchronized (jarFiles) {
-                    if (force || (System.currentTimeMillis()
-                                  > (lastJarAccessed + 90000))) {
+                    if (force || (jarOpenInterval > 0 && System.currentTimeMillis()
+                            > (lastJarAccessed + jarOpenInterval))) {
                         for (int i = 0; i < jarFiles.length; i++) {
                             try {
                                 if (jarFiles[i] != null) {

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java?rev=1818927&r1=1818926&r2=1818927&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappLoader.java Thu Dec 21 14:07:20
2017
@@ -137,6 +137,10 @@ public class WebappLoader extends Lifecy
      */
     private boolean delegate = false;
 
+    /**
+     * The interval in milliseconds to keep all jar files open if no jar is accessed
+     */
+    private int jarOpenInterval = 90000;
 
     /**
      * The descriptive information about this Loader implementation.
@@ -282,6 +286,21 @@ public class WebappLoader extends Lifecy
 
     }
 
+    /**
+     * The interval to keep all jar files open if no jar is accessed
+     *
+     * @param jarOpenInterval The new interval
+     */
+    public void setJarOpenInterval(int jarOpenInterval) {
+        this.jarOpenInterval = jarOpenInterval;
+    }
+
+    /**
+     * Return the interval to keep all jar files open if no jar is accessed
+     */
+    public int getJarOpenInterval() {
+        return jarOpenInterval;
+    }
 
     /**
      * Return descriptive information about this Loader implementation and
@@ -580,6 +599,7 @@ public class WebappLoader extends Lifecy
         try {
 
             classLoader = createClassLoader();
+            classLoader.setJarOpenInterval(this.jarOpenInterval);
             classLoader.setResources(container.getResources());
             classLoader.setDelegate(this.delegate);
             classLoader.setSearchExternalFirst(searchExternalFirst);

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml?rev=1818927&r1=1818926&r2=1818927&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml Thu Dec 21
14:07:20 2017
@@ -169,6 +169,10 @@
              writeable="false" 
                  type="java.lang.String"/>
 
+    <attribute   name="jarOpenInterval"
+                 description="The interval in milliseconds to keep all jar files open if
no jar is accessed"
+                 type="int"/>
+
   </mbean>
 
   <mbean         name="ParallelWebappClassLoader"
@@ -213,6 +217,10 @@
              writeable="false" 
                  type="java.lang.String"/>
 
+    <attribute   name="jarOpenInterval"
+                 description="The interval in milliseconds to keep all jar files open if
no jar is accessed"
+                 type="int"/>
+
   </mbean>
 
 </mbeans-descriptors>

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1818927&r1=1818926&r2=1818927&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Dec 21 14:07:20 2017
@@ -71,6 +71,11 @@
         running under a <code>SecurityManager</code> is an asynchronous Servlet.
         (markt)
       </fix>
+      <add>
+        <bug>61810</bug>: Support configure the interval to keep all jars open
+        if no jar is accessed, a non-positive interval indicates
+        keeping jars always open. (huxing)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Web applications">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message