tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1357413 - in /tomcat/trunk: java/org/apache/catalina/ java/org/apache/catalina/core/ java/org/apache/catalina/mbeans/ test/org/apache/catalina/startup/
Date Wed, 04 Jul 2012 21:22:04 GMT
Author: markt
Date: Wed Jul  4 21:22:03 2012
New Revision: 1357413

URL: http://svn.apache.org/viewvc?rev=1357413&view=rev
Log:
Move Manager from Container to Context

Modified:
    tomcat/trunk/java/org/apache/catalina/Container.java
    tomcat/trunk/java/org/apache/catalina/Context.java
    tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
    tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java

Modified: tomcat/trunk/java/org/apache/catalina/Container.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Container.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Container.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Container.java Wed Jul  4 21:22:03 2012
@@ -122,22 +122,6 @@ public interface Container extends Lifec
 
 
     /**
-     * Return the Manager with which this Container is associated.  If there is
-     * no associated Manager, return the Manager associated with our parent
-     * Container (if any); otherwise return <code>null</code>.
-     */
-    public Manager getManager();
-
-
-    /**
-     * Set the Manager with which this Container is associated.
-     *
-     * @param manager The newly associated Manager
-     */
-    public void setManager(Manager manager);
-
-
-    /**
      * Return the JMX name associated with this container.
      */
     public ObjectName getObjectName();

Modified: tomcat/trunk/java/org/apache/catalina/Context.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Context.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Context.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Context.java Wed Jul  4 21:22:03 2012
@@ -1412,5 +1412,19 @@ public interface Context extends Contain
      * @param resources The newly associated Resources
      */
     public void setResources(DirContext resources);
+
+    /**
+     * Return the Manager with which this Context is associated.  If there is
+     * no associated Manager, return <code>null</code>.
+     */
+    public Manager getManager();
+
+
+    /**
+     * Set the Manager with which this Context is associated.
+     *
+     * @param manager The newly associated Manager
+     */
+    public void setManager(Manager manager);
 }
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java Wed Jul  4 21:22:03 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina.core;
 
-
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.File;
@@ -53,7 +52,6 @@ import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
-import org.apache.catalina.Manager;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Valve;
@@ -196,12 +194,6 @@ public abstract class ContainerBase exte
 
 
     /**
-     * The Manager implementation with which this Container is associated.
-     */
-    protected Manager manager = null;
-
-
-    /**
      * The cluster with which this Container is associated.
      */
     protected Cluster cluster = null;
@@ -374,65 +366,6 @@ public abstract class ContainerBase exte
 
 
     /**
-     * Return the Manager with which this Container is associated.  If there is
-     * no associated Manager, return the Manager associated with our parent
-     * Container (if any); otherwise return <code>null</code>.
-     */
-    @Override
-    public Manager getManager() {
-
-        if (manager != null)
-            return (manager);
-        if (parent != null)
-            return (parent.getManager());
-        return (null);
-
-    }
-
-
-    /**
-     * Set the Manager with which this Container is associated.
-     *
-     * @param manager The newly associated Manager
-     */
-    @Override
-    public synchronized void setManager(Manager manager) {
-
-        // Change components if necessary
-        Manager oldManager = this.manager;
-        if (oldManager == manager)
-            return;
-        this.manager = manager;
-
-        // Stop the old component if necessary
-        if (getState().isAvailable() && (oldManager != null) &&
-            (oldManager instanceof Lifecycle)) {
-            try {
-                ((Lifecycle) oldManager).stop();
-            } catch (LifecycleException e) {
-                log.error("ContainerBase.setManager: stop: ", e);
-            }
-        }
-
-        // Start the new component if necessary
-        if (manager != null)
-            manager.setContainer(this);
-        if (getState().isAvailable() && (manager != null) &&
-            (manager instanceof Lifecycle)) {
-            try {
-                ((Lifecycle) manager).start();
-            } catch (LifecycleException e) {
-                log.error("ContainerBase.setManager: start: ", e);
-            }
-        }
-
-        // Report this property change to interested listeners
-        support.firePropertyChange("manager", oldManager, this.manager);
-
-    }
-
-
-    /**
      * Return the Cluster with which this Container is associated.  If there is
      * no associated Cluster, return the Cluster associated with our parent
      * Container (if any); otherwise return <code>null</code>.
@@ -938,8 +871,6 @@ public abstract class ContainerBase exte
         // Start our subordinate components, if any
         logger = null;
         getLogger();
-        if ((manager != null) && (manager instanceof Lifecycle))
-            ((Lifecycle) manager).start();
         if ((cluster != null) && (cluster instanceof Lifecycle))
             ((Lifecycle) cluster).start();
         Realm realm = getRealmInternal();
@@ -1031,18 +962,11 @@ public abstract class ContainerBase exte
         if ((cluster != null) && (cluster instanceof Lifecycle)) {
             ((Lifecycle) cluster).stop();
         }
-        if ((manager != null) && (manager instanceof Lifecycle) &&
-                ((Lifecycle) manager).getState().isAvailable() ) {
-            ((Lifecycle) manager).stop();
-        }
     }
 
     @Override
     protected void destroyInternal() throws LifecycleException {
 
-        if ((manager != null) && (manager instanceof Lifecycle)) {
-            ((Lifecycle) manager).destroy();
-        }
         Realm realm = getRealmInternal();
         if ((realm != null) && (realm instanceof Lifecycle)) {
             ((Lifecycle) realm).destroy();
@@ -1167,13 +1091,6 @@ public abstract class ContainerBase exte
                 log.warn(sm.getString("containerBase.backgroundProcess.cluster", cluster),
e);
             }
         }
-        if (manager != null) {
-            try {
-                manager.backgroundProcess();
-            } catch (Exception e) {
-                log.warn(sm.getString("containerBase.backgroundProcess.manager", manager),
e);
-            }
-        }
         Realm realm = getRealmInternal();
         if (realm != null) {
             try {

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Wed Jul  4 21:22:03
2012
@@ -64,7 +64,6 @@ asyncContextImpl.requestEnded=The reques
 containerBase.threadedStartFailed=A child container failed during start
 containerBase.threadedStopFailed=A child container failed during stop
 containerBase.backgroundProcess.cluster=Exception processing cluster {0} background process
-containerBase.backgroundProcess.manager=Exception processing manager {0} background process
 containerBase.backgroundProcess.realm=Exception processing realm {0} background process
 containerBase.backgroundProcess.valve=Exception processing valve {0} background process
 defaultInstanceManager.invalidInjection=Invalid method resource injection annotation
@@ -87,6 +86,7 @@ standardContext.invalidWrapperClass={0} 
 standardContext.applicationListener=Error configuring application listener of class {0}
 standardContext.applicationSkipped=Skipped installing application listeners due to previous
error(s)
 standardContext.backgroundProcess.loader=Exception processing loader {0} background process
+standardContext.backgroundProcess.manager=Exception processing manager {0} background process
 standardContext.cluster.noManager=No manager found. Checking if cluster manager should be
used. Cluster configured: [{0}], Application distributable: [{1}]
 standardContext.duplicateListener=The listener "{0}" is already configured for this context.
The duplicate definition has been ignored.
 standardContext.errorPage.error=Error page location {0} must start with a ''/''

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties Wed Jul  4 21:22:03
2012
@@ -54,8 +54,6 @@ aprListener.flags = Capacidades APR\: IP
 aprListener.initializedOpenSSL=OpenSSL inicializado correctamente ({0})
 asyncContextImpl.requestEnded = El requerimiento asociado con AsyncContext ya ha completado
su procesamiento.
 containerBase.backgroundProcess.cluster = Excepci\u00F3n al procesar cl\u00FAster {0} de
proceso en segundo plano
-containerBase.backgroundProcess.loader = Excepci\u00F3n al procesar cargador {0} de proceso
en segundo plano
-containerBase.backgroundProcess.manager = Excepci\u00F3n al procesar gestor {0} de proceso
en segundo plano
 containerBase.backgroundProcess.realm = Excepci\u00F3n al procesar reino {0} de proceso en
segundo plano
 containerBase.backgroundProcess.valve = Excepci\u00F3n al procesar v\u00E1lvula {0} de proceso
en segundo plano
 filterChain.filter = La ejecuci\u00F3n del Filtro lanz\u00F3 una excepci\u00F3n
@@ -75,6 +73,8 @@ naming.namingContextCreationFailed = Fal
 standardContext.invalidWrapperClass = {0} no es una subclase de StandardWrapper
 standardContext.applicationListener = Error configurando escuchador de aplicaci\u00F3n de
clase {0}
 standardContext.applicationSkipped = Se ha saltado la instalaci\u00F3n de escuchadores de
aplicaci\u00F3n debido a error(es) previo(s)
+standardContext.backgroundProcess.loader = Excepci\u00F3n al procesar cargador {0} de proceso
en segundo plano
+standardContext.backgroundProcess.manager = Excepci\u00F3n al procesar gestor {0} de proceso
en segundo plano
 standardContext.cluster.noManager = No se ha hallado el gestor. Revisando si hay que usar
el gestor de cl\u00FAster. Cl\u00FAster configurado\: [{0}], Aplicaci\u00F3n distribu\u00EDble\:
[{1}]
 standardContext.duplicateListener = El escuchador "{0}" ya est\u00E1 configurado para este
contexto. La definici\u00F3n duplicada ha sido ignorada.
 standardContext.errorPage.error = La localizaci\u00F3n de la p\u00E1gina de error 0} debe
de comenzar con ''/''

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Wed Jul  4 21:22:03 2012
@@ -439,6 +439,12 @@ public class StandardContext extends Con
 
 
     /**
+     * The Manager implementation with which this Container is associated.
+     */
+    protected Manager manager = null;
+
+
+    /**
      * The naming context listener for this web application.
      */
     private NamingContextListener namingContextListener = null;
@@ -1904,6 +1910,48 @@ public class StandardContext extends Con
     }
 
 
+    @Override
+    public Manager getManager() {
+        return manager;
+    }
+
+
+    @Override
+    public synchronized void setManager(Manager manager) {
+
+        // Change components if necessary
+        Manager oldManager = this.manager;
+        if (oldManager == manager)
+            return;
+        this.manager = manager;
+
+        // Stop the old component if necessary
+        if (getState().isAvailable() && (oldManager != null) &&
+            (oldManager instanceof Lifecycle)) {
+            try {
+                ((Lifecycle) oldManager).stop();
+            } catch (LifecycleException e) {
+                log.error("StandardContext.setManager: stop: ", e);
+            }
+        }
+
+        // Start the new component if necessary
+        if (manager != null)
+            manager.setContainer(this);
+        if (getState().isAvailable() && (manager != null) &&
+            (manager instanceof Lifecycle)) {
+            try {
+                ((Lifecycle) manager).start();
+            } catch (LifecycleException e) {
+                log.error("StandardContext.setManager: start: ", e);
+            }
+        }
+
+        // Report this property change to interested listeners
+        support.firePropertyChange("manager", oldManager, this.manager);
+    }
+
+
     /**
      * Return the boolean on the annotations parsing.
      */
@@ -5520,6 +5568,10 @@ public class StandardContext extends Con
             ((Lifecycle) loader).destroy();
         }
 
+        if ((manager != null) && (manager instanceof Lifecycle)) {
+            ((Lifecycle) manager).destroy();
+        }
+
         super.destroyInternal();
     }
 
@@ -5534,6 +5586,15 @@ public class StandardContext extends Con
                         "standardContext.backgroundProcess.loader", loader), e);
             }
         }
+        if (manager != null) {
+            try {
+                manager.backgroundProcess();
+            } catch (Exception e) {
+                log.warn(sm.getString(
+                        "standardContext.backgroundProcess.manager", manager),
+                        e);
+            }
+        }
         super.backgroundProcess();
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties Wed Jul  4 21:22:03
2012
@@ -18,3 +18,5 @@ jmxRemoteLifecycleListener.createServerF
 jmxRemoteLifecycleListener.destroyServerFailed=The JMX connector server could not be stopped
for the {0} server
 jmxRemoteLifecycleListener.invalidURL=The JMX Service URL requested for the {0} server, "{1}",
was invalid
 jmxRemoteLifecycleListener.start=The JMX Remote Listener has configured the registry on port
{0} and the server on port {1} for the {2} server
+
+mBeanFactory.managerContext=Manager components may only be added to Contexts.

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java Wed Jul  4 21:22:03 2012
@@ -44,6 +44,7 @@ import org.apache.catalina.realm.UserDat
 import org.apache.catalina.session.StandardManager;
 import org.apache.catalina.startup.ContextConfig;
 import org.apache.catalina.startup.HostConfig;
+import org.apache.tomcat.util.res.StringManager;
 
 
 /**
@@ -59,6 +60,9 @@ public class MBeanFactory {
     private static final org.apache.juli.logging.Log log =
         org.apache.juli.logging.LogFactory.getLog(MBeanFactory.class);
 
+    protected static final StringManager sm =
+            StringManager.getManager(Constants.Package);
+
     /**
      * The <code>MBeanServer</code> for this application.
      */
@@ -615,8 +619,10 @@ public class MBeanFactory {
         // Add the new instance to its parent component
         ObjectName pname = new ObjectName(parent);
         Container container = getParentContainerFromParent(pname);
-        if (container != null) {
-            container.setManager(manager);
+        if (container instanceof Context) {
+            ((Context) container).setManager(manager);
+        } else {
+            throw new Exception(sm.getString("mBeanFactory.managerContext"));
         }
         ObjectName oname = manager.getObjectName();
         if (oname != null) {
@@ -870,8 +876,9 @@ public class MBeanFactory {
         ObjectName oname = new ObjectName(name);
         // Acquire a reference to the component to be removed
         Container container = getParentContainerFromChild(oname);
-        container.setManager(null);
-
+        if (container instanceof Context) {
+            ((Context) container).setManager(null);
+        }
     }
 
 

Modified: tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1357413&r1=1357412&r2=1357413&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Wed Jul  4 21:22:03
2012
@@ -39,6 +39,7 @@ import org.junit.After;
 import org.junit.Before;
 
 import org.apache.catalina.Container;
+import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Server;
@@ -402,12 +403,13 @@ public abstract class TomcatBaseTest ext
                 Container e = service.getContainer();
                 for (Container h : e.findChildren()) {
                     for (Container c : h.findChildren()) {
-                        StandardManager m = (StandardManager) c.getManager();
+                        StandardManager m =
+                                (StandardManager) ((Context) c).getManager();
                         if (m == null) {
                             m = new StandardManager();
                             m.setSecureRandomClass(
                                     "org.apache.catalina.startup.FastNonSecureRandom");
-                            c.setManager(m);
+                            ((Context) c).setManager(m);
                         }
                     }
                 }



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


Mime
View raw message