This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new f6d471f  Remove reloadable attribute from Loader (it is duplicated on 
Context)
f6d471f is described below

commit f6d471f6ff69a5f3da00cd8f8216b4c513ca069f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 20:56:48 2020 +0100

    Remove reloadable attribute from Loader (it is duplicated on Context)
---
 java/org/apache/catalina/Loader.java               | 14 ----
 java/org/apache/catalina/loader/WebappLoader.java  | 95 +++-------------------
 .../apache/catalina/loader/mbeans-descriptors.xml  |  4 -
 .../startup/TestContextConfigAnnotation.java       |  4 -
 webapps/docs/changelog.xml                         |  5 ++
 webapps/docs/config/loader.xml                     | 17 ----
 6 files changed, 15 insertions(+), 124 deletions(-)

diff --git a/java/org/apache/catalina/Loader.java 
b/java/org/apache/catalina/Loader.java
index dfe2461..66c080d 100644
--- a/java/org/apache/catalina/Loader.java
+++ b/java/org/apache/catalina/Loader.java
@@ -95,20 +95,6 @@ public interface Loader {
 
 
     /**
-     * @return the reloadable flag for this Loader.
-     */
-    public boolean getReloadable();
-
-
-    /**
-     * Set the reloadable flag for this Loader.
-     *
-     * @param reloadable The new reloadable flag
-     */
-    public void setReloadable(boolean reloadable);
-
-
-    /**
      * Add a property change listener to this component.
      *
      * @param listener The listener to add
diff --git a/java/org/apache/catalina/loader/WebappLoader.java 
b/java/org/apache/catalina/loader/WebappLoader.java
index 2727a31..03c738b 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina.loader;
 
-import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.File;
@@ -62,8 +61,7 @@ import org.apache.tomcat.util.res.StringManager;
  * @author Craig R. McClanahan
  * @author Remy Maucherat
  */
-public class WebappLoader extends LifecycleMBeanBase
-    implements Loader, PropertyChangeListener {
+public class WebappLoader extends LifecycleMBeanBase implements Loader{
 
     private static final Log log = LogFactory.getLog(WebappLoader.class);
 
@@ -97,12 +95,6 @@ public class WebappLoader extends LifecycleMBeanBase
 
 
     /**
-     * The reloadable flag for this Loader.
-     */
-    private boolean reloadable = false;
-
-
-    /**
      * The string manager for this package.
      */
     protected static final StringManager sm = 
StringManager.getManager(WebappLoader.class);
@@ -145,25 +137,13 @@ public class WebappLoader extends LifecycleMBeanBase
         }
 
         if (getState().isAvailable()) {
-            throw new IllegalStateException(
-                    sm.getString("webappLoader.setContext.ise"));
-        }
-
-        // Deregister from the old Context (if any)
-        if (this.context != null) {
-            this.context.removePropertyChangeListener(this);
+            throw new 
IllegalStateException(sm.getString("webappLoader.setContext.ise"));
         }
 
         // Process this property change
         Context oldContext = this.context;
         this.context = context;
         support.firePropertyChange("context", oldContext, this.context);
-
-        // Register with the new Container (if any)
-        if (this.context != null) {
-            setReloadable(this.context.getReloadable());
-            this.context.addPropertyChangeListener(this);
-        }
     }
 
 
@@ -210,31 +190,6 @@ public class WebappLoader extends LifecycleMBeanBase
     }
 
 
-    /**
-     * Return the reloadable flag for this Loader.
-     */
-    @Override
-    public boolean getReloadable() {
-        return this.reloadable;
-    }
-
-
-    /**
-     * Set the reloadable flag for this Loader.
-     *
-     * @param reloadable The new reloadable flag
-     */
-    @Override
-    public void setReloadable(boolean reloadable) {
-        // Process this property change
-        boolean oldReloadable = this.reloadable;
-        this.reloadable = reloadable;
-        support.firePropertyChange("reloadable",
-                                   Boolean.valueOf(oldReloadable),
-                                   Boolean.valueOf(this.reloadable));
-    }
-
-
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -257,17 +212,15 @@ public class WebappLoader extends LifecycleMBeanBase
      */
     @Override
     public void backgroundProcess() {
-        if (reloadable && modified()) {
-            try {
-                Thread.currentThread().setContextClassLoader
-                    (WebappLoader.class.getClassLoader());
-                if (context != null) {
+        Context context = getContext();
+        if (context != null) {
+            if (context.getReloadable() && modified()) {
+                ClassLoader originalTccl = 
Thread.currentThread().getContextClassLoader();
+                try {
+                    
Thread.currentThread().setContextClassLoader(WebappLoader.class.getClassLoader());
                     context.reload();
-                }
-            } finally {
-                if (context != null && context.getLoader() != null) {
-                    Thread.currentThread().setContextClassLoader
-                        (context.getLoader().getClassLoader());
+                } finally {
+                    Thread.currentThread().setContextClassLoader(originalTccl);
                 }
             }
         }
@@ -437,34 +390,6 @@ public class WebappLoader extends LifecycleMBeanBase
     }
 
 
-    // ----------------------------------------- PropertyChangeListener Methods
-
-
-    /**
-     * Process property change events from our associated Context.
-     *
-     * @param event The property change event that has occurred
-     */
-    @Override
-    public void propertyChange(PropertyChangeEvent event) {
-
-        // Validate the source of this event
-        if (!(event.getSource() instanceof Context))
-            return;
-
-        // Process a relevant property change
-        if (event.getPropertyName().equals("reloadable")) {
-            try {
-                setReloadable
-                    ( ((Boolean) event.getNewValue()).booleanValue() );
-            } catch (NumberFormatException e) {
-                log.error(sm.getString("webappLoader.reloadable",
-                                 event.getNewValue().toString()));
-            }
-        }
-    }
-
-
     // ------------------------------------------------------- Private Methods
 
     /**
diff --git a/java/org/apache/catalina/loader/mbeans-descriptors.xml 
b/java/org/apache/catalina/loader/mbeans-descriptors.xml
index 597ea51..c93596f 100644
--- a/java/org/apache/catalina/loader/mbeans-descriptors.xml
+++ b/java/org/apache/catalina/loader/mbeans-descriptors.xml
@@ -32,10 +32,6 @@
           description="The 'follow standard delegation model' flag that will 
be used to configure our ClassLoader"
                  type="boolean"/>
 
-    <attribute   name="reloadable"
-          description="The reloadable flag for this Loader"
-                 type="boolean"/>
-
     <attribute   name="stateName"
           description="The name of the LifecycleState that this component is 
currently in"
                  type="java.lang.String"
diff --git a/test/org/apache/catalina/startup/TestContextConfigAnnotation.java 
b/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
index 8e4f2b6..d20af63 100644
--- a/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
+++ b/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
@@ -343,10 +343,6 @@ public class TestContextConfigAnnotation {
         @Override
         public void setDelegate(boolean delegate) {}
         @Override
-        public boolean getReloadable() { return false; }
-        @Override
-        public void setReloadable(boolean reloadable) {}
-        @Override
         public void addPropertyChangeListener(PropertyChangeListener l) {
         }
         @Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index cb70a71..8f2bf49 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -57,6 +57,11 @@
         it does not contain a charset. Also remove the outdated workaround for
         the buggy Adobe Reader 9 plug-in for IE. (markt)
       </fix>
+      <scode>
+        Remove the <code>reloadable</code> attribute from the
+        <code>Loader</code> interface as it is duplicated on the
+        <code>Context</code> interface. (markt)
+      </scode>
     </changelog>
   </subsection>
 </section>
diff --git a/webapps/docs/config/loader.xml b/webapps/docs/config/loader.xml
index b8ad79b..16cb521 100644
--- a/webapps/docs/config/loader.xml
+++ b/webapps/docs/config/loader.xml
@@ -89,23 +89,6 @@
         parent class loaders to find requested classes or resources.</p>
       </attribute>
 
-      <attribute name="reloadable" required="false">
-        <p>Set to <code>true</code> if you want Catalina to monitor classes in
-        <code>/WEB-INF/classes/</code> and <code>/WEB-INF/lib</code> for
-        changes, and automatically reload the web application if a change
-        is detected.  This feature is very useful during application
-        development, but it requires significant runtime overhead and is
-        not recommended for use on deployed production applications.  You
-        can use the <a href="../manager-howto.html">Manager</a> web
-        application, however, to trigger reloads of deployed applications
-        on demand.</p>
-
-        <p><strong>NOTE</strong> - The value for this property will be
-        inherited from the <code>reloadable</code> attribute you set on
-        the surrounding <a href="context.html">Context</a> component,
-        and any value you explicitly set here will be replaced.</p>
-      </attribute>
-
     </attributes>
 
   </subsection>


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

Reply via email to