tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r996231 - in /tomcat/trunk: java/org/apache/catalina/ java/org/apache/catalina/core/ java/org/apache/catalina/mbeans/ java/org/apache/catalina/startup/ webapps/docs/
Date Sun, 12 Sep 2010 01:25:03 GMT
Author: markt
Date: Sun Sep 12 01:25:03 2010
New Revision: 996231

URL: http://svn.apache.org/viewvc?rev=996231&view=rev
Log:
Further work for https://issues.apache.org/bugzilla/show_bug.cgi?id=49234
GSOC 2010. Enable the creation of Services, Engines, Connectors, Hosts and Contexts via JMX from a minimal server.xml that contains only a Server element.
Based on a patch by Chamith Buddhika. I added the additional changes to pass the parent class loader down the hierarchy.

Added:
    tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java   (with props)
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java   (with props)
    tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java   (with props)
Modified:
    tomcat/trunk/java/org/apache/catalina/Server.java
    tomcat/trunk/java/org/apache/catalina/Service.java
    tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
    tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
    tomcat/trunk/java/org/apache/catalina/core/StandardService.java
    tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
    tomcat/trunk/java/org/apache/catalina/startup/Catalina.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/Server.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Server.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Server.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Server.java Sun Sep 12 01:25:03 2010
@@ -19,6 +19,7 @@
 package org.apache.catalina;
 
 import org.apache.catalina.deploy.NamingResources;
+import org.apache.catalina.startup.Catalina;
 
 /**
  * A <code>Server</code> element represents the entire Catalina
@@ -115,7 +116,23 @@ public interface Server extends Lifecycl
      */
     public void setShutdown(String shutdown);
 
+    
+    /**
+     * Return the parent class loader.
+     */
+    public ClassLoader getParentClassLoader();
 
+    
+    /**
+     * Return the outer Catalina startup/shutdown component if present.
+     */
+    public Catalina getCatalina();
+    
+    /**
+     * Set the outer Catalina startup/shutdown component if present.
+     */
+    public void setCatalina(Catalina catalina);
+    
     // --------------------------------------------------------- Public Methods
 
 

Modified: tomcat/trunk/java/org/apache/catalina/Service.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Service.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Service.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Service.java Sun Sep 12 01:25:03 2010
@@ -84,6 +84,11 @@ public interface Service extends Lifecyc
      */
     public void setServer(Server server);
 
+    /**
+     * Return the parent class loader.
+     */
+    public ClassLoader getParentClassLoader();
+    
     // --------------------------------------------------------- Public Methods
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java Sun Sep 12 01:25:03 2010
@@ -26,10 +26,12 @@ import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.Realm;
+import org.apache.catalina.Server;
 import org.apache.catalina.Service;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.realm.JAASRealm;
+import org.apache.catalina.startup.Catalina;
 import org.apache.catalina.util.LifecycleBase;
 import org.apache.catalina.util.ServerInfo;
 import org.apache.juli.logging.Log;
@@ -333,6 +335,19 @@ public class StandardEngine extends Cont
     }
 
 
+    /**
+     * Return the parent class loader for this component.
+     */
+    @Override
+    public ClassLoader getParentClassLoader() {
+        if (parentClassLoader != null)
+            return (parentClassLoader);
+        if (service != null) {
+            return (service.getParentClassLoader());
+        }
+        return (ClassLoader.getSystemClassLoader());
+    }
+
     // -------------------- JMX registration  --------------------
 
     @Override

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardServer.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Sun Sep 12 01:25:03 2010
@@ -40,6 +40,7 @@ import org.apache.catalina.Service;
 import org.apache.catalina.deploy.NamingResources;
 import org.apache.catalina.mbeans.MBeanFactory;
 import org.apache.catalina.mbeans.MBeanUtils;
+import org.apache.catalina.startup.Catalina;
 import org.apache.catalina.util.LifecycleBase;
 import org.apache.catalina.util.LifecycleMBeanBase;
 import org.apache.catalina.util.ServerInfo;
@@ -156,6 +157,8 @@ public final class StandardServer extend
     protected PropertyChangeSupport support = new PropertyChangeSupport(this);
 
     private boolean stopAwait = false;
+    
+    private Catalina catalina = null;
 
     // ------------------------------------------------------------- Properties
 
@@ -297,6 +300,23 @@ public final class StandardServer extend
     }
 
 
+    /**
+     * Return the outer Catalina startup/shutdown component if present.
+     */
+    @Override
+    public Catalina getCatalina() {
+        return catalina;
+    }
+    
+    
+    /**
+     * Set the outer Catalina startup/shutdown component if present.
+     */
+    @Override
+    public void setCatalina(Catalina catalina) {
+        this.catalina = catalina;
+    }
+    
     // --------------------------------------------------------- Server Methods
 
 
@@ -721,6 +741,17 @@ public final class StandardServer extend
         super.destroyInternal();
     }
 
+    /**
+     * Return the parent class loader for this component.
+     */
+    @Override
+    public ClassLoader getParentClassLoader() {
+        if (catalina != null) {
+            return (catalina.getParentClassLoader());
+        }
+        return (ClassLoader.getSystemClassLoader());
+    }
+
     private ObjectName onameStringCache;
     private ObjectName onameMBeanFactory;
     private ObjectName onameNamingResoucres;

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardService.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardService.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardService.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardService.java Sun Sep 12 01:25:03 2010
@@ -579,6 +579,17 @@ public class StandardService extends Lif
         super.destroyInternal();
     }
 
+    /**
+     * Return the parent class loader for this component.
+     */
+    @Override
+    public ClassLoader getParentClassLoader() {
+        if (server != null) {
+            return (server.getParentClassLoader());
+        }
+        return (ClassLoader.getSystemClassLoader());
+    }
+
     @Override
     protected String getDomainInternal() {
         

Modified: tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml Sun Sep 12 01:25:03 2010
@@ -62,7 +62,8 @@
          description="Standard Context Component"
          domain="Catalina"
          group="Context"
-         type="org.apache.catalina.core.StandardContext">
+         type="org.apache.catalina.core.StandardContext"
+         className="org.apache.catalina.mbeans.ContextMBean">
     
     <attribute name="allowLinking"
                description="Allow symlinking to outside the webapp root directory, if the webapp is an exploded directory"
@@ -390,49 +391,376 @@
     <attribute name="xmlNamespaceAware"
                description="Should XML namespace validation be turned on?"
                type="boolean"/>
+               
+    <operation name="addApplicationListener"
+               description="Add a new Listener class name to the set of Listeners configured for this application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Java class name of a listener class"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addApplicationParameter"
+               description="Add a new application parameter for this application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Java class name of a listener class"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addChild"
+               description="Add a child to this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new child to be added"
+                 type="java.lang.String"/>
+      <parameter name="name"
+                 description="Name of the child to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addInstanceListener"
+               description="Add the classname of an InstanceListener to be added to each Wrapper appended to this Context."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Java class name of an InstanceListener class"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addLifecycleListener"
+               description="Add a lifecycle listener to this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new lifecycle listener to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addLocaleEncodingMappingParameter"
+               description="Add a Locale Encoding Mapping"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="locale"
+                 description="Locale to map an encoding for"
+                 type="java.lang.String"/>
+      <parameter name="encoding"
+                 description="Encoding to be used for a give locale"
+                 type="java.lang.String"/>
+    </operation>
+
+    <operation name="addMimeMapping"
+               description="Add a new MIME mapping, replacing any existing mapping for the specified extension."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="extension"
+                 description="Filename extension being mapped"
+                 type="java.lang.String"/>
+      <parameter name="mimeType"
+                 description="Corresponding MIME type"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addParameter"
+               description="Add a new context initialization parameter, replacing any existing value for the specified name."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the new parameter"
+                 type="java.lang.String"/>
+      <parameter name="value"
+                 description="Value of the new  parameter"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addRoleMapping"
+               description="Add a security role reference for this web application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="role"
+                 description="Security role used in the application"
+                 type="java.lang.String"/>
+      <parameter name="link"
+                 description="Actual security role to check for"
+                 type="java.lang.String"/>
+    </operation>
 
+    <operation name="addSecurityRole"
+               description="Add a new security role for this web application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="role"
+                 description="New security role"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addServletMapping"
+               description="Add a new servlet mapping, replacing any existing mapping for the specified pattern."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="pattern"
+                 description="URL pattern to be mapped"
+                 type="java.lang.String"/>
+      <parameter name="name"
+                 description="Name of the corresponding servlet to execute"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addServletMapping"
+               description="Add a new servlet mapping, replacing any existing mapping for the specified pattern."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="pattern"
+                 description="URL pattern to be mapped"
+                 type="java.lang.String"/>
+      <parameter name="name"
+                 description="Name of the corresponding servlet to execute"
+                 type="java.lang.String"/>
+      <parameter name="jspWildcard"
+                 description="'true' if name identifies the JspServlet and pattern contains a wildcard; 'false' otherwise"
+                 type="boolean"/>
+    </operation>
+    
     <operation name="addValve"
                description="Add a valve to this Context"
                impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="valveType"
+                 description="Type(classname) of the new valve to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addWatchedResource"
+               description=" Add a resource which will be watched for reloading by the host auto deployer."
+               impact="ACTION"
                returnType="void">
-      <parameter name="valve"
-                 description="New valve to be added"
-                 type="org.apache.catalina.Valve"/>
+      <parameter name="name"
+                 description="Path to the resource, relative to docBase"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="removeValve"
-               description="Remove a valve from this Context"
+    <operation name="addWelcomeFile"
+               description="Add a new welcome file to the set recognized by this Context."
                impact="ACTION"
                returnType="void">
-      <parameter name="valve"
-                 description="New valve to be removed"
-                 type="org.apache.catalina.Valve"/>
+      <parameter name="name"
+                 description="New welcome file name"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="addLifecycleListener"
-               description="Add a lifecycle listener to this Context"
+    <operation name="addWrapperLifecycle"
+               description="Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context."
                impact="ACTION"
                returnType="void">
       <parameter name="listener"
-                 description="New lifecycle listener to be added"
-                 type="org.apache.catalina.LifecycleListener"/>
+                 description="Java class name of a LifecycleListener class"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="removeLifecycleListener"
-               description="Remove a lifecycle listener from this Context"
+    <operation name="addWrapperListener"
+               description="Add the classname of a ContainerListener to be added to each Wrapper appended to this Context."
                impact="ACTION"
                returnType="void">
       <parameter name="listener"
-                 description="New lifecycle listener to be removed"
-                 type="org.apache.catalina.LifecycleListener"/>
+                 description="Java class name of a ContainerListener class"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="reload"
-               description="Reload the webapplication"
+    <operation name="destroy"
+               description="Destroy the context"
                impact="ACTION"
                returnType="void">
     </operation>
     
+    <operation name="findApplicationListeners"
+               description="Return the set of application listener class names configured for this application."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">    
+    </operation>
+    
+    <operation name="findApplicationParameters"
+               description="Return the set of application parameters for this application."
+               impact="INFO"
+               returnType="java.lang.String">    
+    </operation>
+    
+    <operation name="findConstraints"
+               description="Return the set of security constraints for this web application. If there are none, a zero-length array is returned."
+               impact="INFO"
+               returnType="java.lang.String">    
+    </operation>
+    
+    <operation name="findErrorPage"
+               description="Return the error page entry for the specified HTTP error code, if any; otherwise return null"
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="errorCode"
+                 description="Error code to look up"
+                 type="int"/>
+    </operation>
+    
+    <operation name="findErrorPage"
+               description="Return the error page entry for the specified Java exception type, if any; otherwise return null."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="exceptionType"
+                 description="Exception type to look up"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findErrorPages"
+               description="Return the set of defined error pages for all specified error codes and exception types."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">    
+    </operation>
+    
+    <operation name="findFilterDef"
+               description="Return the filter definition for the specified filter name, if any; otherwise return null."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="exceptionType"
+                 description="Exception type to look up"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findFilterDefs"
+               description="Return the set of defined filters for this Context."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">    
+    </operation>
+    
+    <operation name="findFilterMaps"
+               description="Return the set of filter mappings for this Context."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">    
+    </operation>
+    
+    <operation name="findInstanceListeners"
+               description="Return the set of InstanceListener classes that will be added to newly created Wrappers automatically."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">    
+    </operation>
+    
+    <operation name="findMimeMapping"
+               description="Return the MIME type to which the specified extension is mapped, if any; otherwise return null."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="extension"
+                 description="Extension to map to a MIME type"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findMimeMappings"
+               description="Return the extensions for which MIME mappings are defined."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findParameter"
+               description="Return the value for the specified context initialization parameter name, if any; otherwise return null."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="name"
+                 description="Name of the parameter to return"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findParameters"
+               description="Return the names of all defined context initialization parameters for this Context."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findRoleMapping"
+               description="For the given security role (as used by an application), return the corresponding role name (as defined by the underlying Realm) if there is one.  Otherwise, return the specified role unchanged."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="role"
+                 description="Security role to map"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findSecurityRole"
+               description="Return 'true' if the specified security role is defined for this application; otherwise return 'false'."
+               impact="ACTION"
+               returnType="boolean">
+      <parameter name="role"
+                 description="Security role to verify"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findSecurityRoles"
+               description="Return the security roles defined for this application."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findServletMapping"
+               description="Return the servlet name mapped by the specified pattern.."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="pattern"
+                 description="Pattern for which a mapping is requested"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findServletMappings"
+               description="Return the patterns of all defined servlet mappings for this Context."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findStatusPage"
+               description="Return the context-relative URI of the error page for the specified HTTP status code."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="status"
+                 description="HTTP status code to look up"
+                 type="int"/>
+    </operation>
+    
+    <operation name="findStatusPages"
+               description="Return the set of HTTP status codes for which error pages have been specified."
+               impact="ACTION"
+               returnType="[Lint">
+    </operation>
+    
+    <operation name="findWatchedResources"
+               description="Return the set of watched resources for this Context."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findWelcomeFile"
+               description="Return 'true' if the specified welcome file is defined for this Context; otherwise return 'false'."
+               impact="ACTION"
+               returnType="boolean">
+      <parameter name="name"
+                 description="Welcome file to verify"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findWelcomeFiles"
+               description="Return the set of welcome files defined for this Context."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findWrapperLifecycles"
+               description="Return the set of LifecycleListener classes that will be added to newly created Wrappers automatically."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="findWrapperListeners"
+               description="Return the set of ContainerListener classes that will be added to newly created Wrappers automatically."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
     <operation name="init"
                description="Register the context into the running server"
                impact="ACTION"
@@ -451,24 +779,157 @@
                returnType="void">
     </operation>
     
-    <operation name="destroy"
-               description="Destroy the context"
+    <operation name="reload"
+               description="Reload the webapplication"
                impact="ACTION"
                returnType="void">
     </operation>
     
-    <operation name="findMappingObject"
-               description="Return an object which may be utilized for mapping to this component"
-               impact="INFO"
-               returnType="org.apache.catalina.Context">    
-    </operation>    
+    <operation name="removeApplicationListener"
+               description="Remove the specified application listener class from the set of listeners for this application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Java class name of the listener to be removed"
+                 type="java.lang.String"/>
+    </operation>   
     
-    <operation name="findStaticResources"
-               description="Return the naming resources associated with this web application"
-               impact="INFO"
-               returnType="javax.naming.directory.DirContext">    
+    <operation name="removeApplicationParameter"
+               description="Remove the application parameter with the specified name from the set for this application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the application parameter to remove"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeChild"
+               description="Remove a child from this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the existing child Container to be removed"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="removeInstanceListener"
+               description="Remove the application parameter with the specified name from the set for this application."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Class name of an InstanceListener class to be removed"
+                 type="java.lang.String"/>
+    </operation>        
+    
+    <operation name="removeLifecycleListeners"
+               description="Removes lifecycle listeners of given class type from this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Type(classname) of the lifecycle listeners to be removed"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="removeMimeMapping"
+               description="Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="extension"
+                 description="Extension to remove the mapping for"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeParameter"
+               description="Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the parameter to remove"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="removeRoleMapping"
+               description="Remove any security role reference for the specified name"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="role"
+                 description="Security role (as used in the application) to remove"
+                 type="java.lang.String"/>
+    </operation>  
+    
+    <operation name="removeSecurityRole"
+               description="Remove any security role with the specified name."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="role"
+                 description="Security role to remove"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeServletMapping"
+               description="Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="pattern"
+                 description="URL pattern of the mapping to remove"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeValve"
+               description="Remove a valve from this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="valveName"
+                 description="Objectname of the valve to be removed"
+                 type="java.lang.String"/>
     </operation>
     
+    <operation name="removeWatchedResource"
+               description="Remove the specified watched resource name from the list associated with this Context."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the watched resource to be removed"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeWelcomeFile"
+               description="Remove the specified welcome file name from the list recognized by this Context."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the welcome file to be removed"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeWrapperLifecycle"
+               description="Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Class name of a LifecycleListener class to be removed"
+                 type="java.lang.String"/>
+    </operation> 
+    
+    <operation name="removeWrapperListener"
+               description="Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Class name of a ContainerListener class to be removed"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="start" 
+               description="Start" 
+               impact="ACTION" 
+               returnType="void" /> 
+
+    <operation name="stop" 
+               description="Stop" 
+               impact="ACTION" 
+               returnType="void" /> 
+    
   </mbean>
   
   <mbean name="StandardContextValve"
@@ -496,7 +957,8 @@
          type="org.apache.catalina.core.StandardEngine"
          description="Standard Engine Component"
          domain="Catalina"
-         group="Engine">
+         group="Engine"
+         className="org.apache.catalina.mbeans.ContainerMBean">
     
     <attribute name="backgroundProcessorDelay"
                description="The processor delay for this component."
@@ -541,19 +1003,84 @@
     <attribute name="valveObjectNames"
                description="ObjectNames for the valves associated with this container"
                type="[Ljavax.management.ObjectName;"
-               writeable="false"/>           
-
+               writeable="false"/>  
+               
     <operation name="addChild"
                description="Add a virtual host"
                impact="ACTION"
                returnType="void">
-      <parameter name="child"
-                 description="Host object"
-                 type="org.apache.catalina.Container"/>
+      <parameter name="type"
+                 description="Type(classname) of the new child to be added"
+                 type="java.lang.String"/>
+      <parameter name="name"
+                 description="Name of the child to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addLifecycleListener"
+               description="Add a lifecycle listener to this Engine"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new lifecycle listener to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addValve"
+               description="Add a valve to this Engine"
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="valveType"
+                 description="Type(classname) of the new valve to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="destroy" 
+               description="Destroy" 
+               impact="ACTION" 
+               returnType="void" />
+               
+    <operation name="init" 
+               description="Init" 
+               impact="ACTION" 
+               returnType="void" />
+    
+    <operation name="removeChild"
+               description="Remove a child(Host) from this Engine"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the existing child Container to be removed"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="start" description="Start" impact="ACTION" returnType="void" />
-    <operation name="stop" description="Stop" impact="ACTION" returnType="void" />
+    <operation name="removeLifecycleListeners"
+               description="Removes lifecycle listeners of given class type from this Engine"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="Type(classname) of the lifecycle listeners to be removed"
+                 type="java.lang.String"/>
+    </operation>    
+    
+    <operation name="removeValve"
+               description="Remove a valve from this Engine"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="valveName"
+                 description="Objectname of the valve to be removed"
+                 type="java.lang.String"/>
+    </operation>  
+    
+    <operation name="start" 
+               description="Start" 
+               impact="ACTION" 
+               returnType="void" /> 
+    
+    <operation name="stop" 
+               description="Stop" 
+               impact="ACTION" 
+               returnType="void" />
       
   </mbean>
 
@@ -583,7 +1110,8 @@
          description="Standard Host Component"
          domain="Catalina"
          group="Host"
-         type="org.apache.catalina.core.StandardHost">
+         type="org.apache.catalina.core.StandardHost"
+         className="org.apache.catalina.mbeans.ContainerMBean">
     
     <attribute name="aliases"
                description="Host aliases"
@@ -683,8 +1211,8 @@
       
     <attribute name="xmlValidation"
                description="Attribute value used to turn on/off XML validation"
-               type="boolean"/>   
-      
+               type="boolean"/> 
+               
     <operation name="addAlias"
                description="Add an alias name that should be mapped to this Host"
                impact="ACTION"
@@ -693,20 +1221,57 @@
                  description="The alias to be added"
                  type="java.lang.String"/>
     </operation>
+               
+    <operation name="addChild"
+               description="Add a child(Context) to this Host"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new child to be added"
+                 type="java.lang.String"/>
+      <parameter name="name"
+                 description="Name of the child to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addLifecycleListener"
+               description="Add a lifecycle listener to this Host"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new lifecycle listener to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addValve"
+               description="Add a valve to this Host"
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="valveType"
+                 description="Type(classname) of the new valve to be added"
+                 type="java.lang.String"/>
+    </operation>
+                   
+    <operation name="destroy" 
+               description="Destroy" 
+               impact="ACTION" 
+               returnType="void" />
     
     <operation name="findAliases"
                description="Return the set of alias names for this Host"
                impact="INFO"
                returnType="[Ljava.lang.String;"/>
-
-    <operation name="addChild"
-               description="Add a context"
-               impact="ACTION">
-      <parameter name="child"
-                 description="Context to be added"
-                 type="org.apache.catalina.Container"/>
-    </operation>
-      
+               
+    <operation name="findReloadedContextMemoryLeaks"
+               description="Provide a list of contexts that have leaked memory on reload. This will attempt to force a full garbage collection. Use with extreme caution on production systems."
+               impact="ACTION"
+               returnType="[Ljava.lang.String;" />
+               
+    <operation name="init" 
+               description="Init" 
+               impact="ACTION" 
+               returnType="void" />
+               
     <operation name="removeAlias"
                description="Remove the specified alias name from the aliases for this  Host"
                impact="ACTION"
@@ -716,15 +1281,42 @@
                  type="java.lang.String"/>
     </operation>
     
-    <operation name="start" description="Start" impact="ACTION" returnType="void" />
-    <operation name="stop" description="Stop" impact="ACTION" returnType="void" />
-    <operation name="init" description="Init" impact="ACTION" returnType="void" />
-    <operation name="destroy" description="Destroy" impact="ACTION" returnType="void" />
+    <operation name="removeChild"
+               description="Remove a child(Context) from this Host"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of the existing child Container to be removed"
+                 type="java.lang.String"/>
+    </operation>
     
-    <operation name="findReloadedContextMemoryLeaks"
-               description="Provide a list of contexts that have leaked memory on reload. This will attempt to force a full garbage collection. Use with extreme caution on production systems."
+    <operation name="removeLifecycleListeners"
+               description="Removes lifecycle listeners of given class type from this Host"
                impact="ACTION"
-               returnType="[Ljava.lang.String;" />
+               returnType="void">
+      <parameter name="listener"
+                 description="Type(classname) of the lifecycle listeners to be removed"
+                 type="java.lang.String"/>
+    </operation>  
+    
+    <operation name="removeValve"
+               description="Remove a valve from this Host"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="valveName"
+                 description="Objectname of the valve to be removed"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="start" 
+               description="Start" 
+               impact="ACTION" 
+               returnType="void" />
+    
+    <operation name="stop" 
+               description="Stop" 
+               impact="ACTION" 
+               returnType="void" />
 
   </mbean>
   
@@ -804,30 +1396,27 @@
          description="Standard Service Component"
          domain="Catalina"
          group="Service"
-         type="org.apache.catalina.core.StandardService">
+         type="org.apache.catalina.core.StandardService"
+         className="org.apache.catalina.mbeans.ServiceMBean">
     
-    <attribute name="managedResource"
-               description="The managed resource this MBean is associated with"
-               type="java.lang.Object"/>
-      
-    <attribute name="name"
-               description="Unique name of this Service"
-               type="java.lang.String"/>
-      
     <attribute name="connectorNames"
                description="ObjectNames of the connectors"
                type="[Ljavax.management.ObjectName;"
                writeable="false" />
       
-    <attribute name="container"
-               description="Servlet engine that will process the requests"
-               type="org.apache.catalina.Container" />
-
     <attribute name="containerName"
                description="ObjectNames of the engine"
                type="javax.management.ObjectName"
                writeable="false" />
 
+    <attribute name="managedResource"
+               description="The managed resource this MBean is associated with"
+               type="java.lang.Object"/>
+      
+    <attribute name="name"
+               description="Unique name of this Service"
+               type="java.lang.String"/>
+      
     <attribute name="stateName"
                description="The name of the LifecycleState that this component is currently in"
                type="java.lang.String"/>
@@ -836,13 +1425,59 @@
                description="Add a new connector"
                impact="ACTION"
                returnType="void">
-      <parameter name="connector"
-                 description="Connector object"
-                 type="org.apache.catalina.connector.Connector"/>
+      <parameter name="address"
+                 description="The IP address on which to bind"
+                 type="java.lang.String"/>
+      <parameter name="port"
+                 description="TCP port number to listen on"
+                 type="int"/>
+      <parameter name="isAjp"
+                 description="Create a AJP/1.3 Connector"
+                 type="boolean"/>
+      <parameter name="isSSL"
+                 description="Create a secure Connector"
+                 type="boolean"/>
     </operation>
     
-    <operation name="start" description="Start" impact="ACTION" returnType="void" />
-    <operation name="stop" description="Stop" impact="ACTION" returnType="void" />
+    <operation name="addExecutor"
+               description="Adds a named executor to the service"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Classname of the Executor to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findConnectors"
+               description="Find and return the set of Connectors associated with this Service"
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+
+    <operation name="findExecutors"
+               description="Retrieves all executors"
+               impact="ACTION"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="getExecutor"
+               description="Retrieves executor by name"
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="name"
+                 description="Name of the executor to be retrieved"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="start" 
+               description="Start" 
+               impact="ACTION" 
+               returnType="void" />
+               
+    <operation name="stop" 
+               description="Stop" 
+               impact="ACTION" 
+               returnType="void" />
   </mbean>
   
   <mbean name="StandardThreadExecutor"
@@ -926,7 +1561,8 @@
          description="Wrapper that represents an individual servlet definition"
          domain="Catalina"
          group="Wrapper"
-         type="org.apache.catalina.core.StandardWrapper">
+         type="org.apache.catalina.core.StandardWrapper"
+         className="org.apache.catalina.mbeans.ContainerMBean">
          
     <attribute name="asyncSupported"
                description="Async support"
@@ -1041,6 +1677,72 @@
                is="true"
                type="boolean"
                writeable="false"/>
+               
+    <operation name="addInitParameter"
+               description="Add a valve to this Wrapper"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Name of this initialization parameter to add"
+                 type="java.lang.String"/>
+      <parameter name="value"
+                 description="Value of this initialization parameter to add"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addLifecycleListener"
+               description="Add a lifecycle listener to this Wrapper"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="type"
+                 description="Type(classname) of the new lifecycle listener to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addMapping"
+               description="Add a mapping associated with the Wrapper."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="mapping"
+                 description="The new wrapper mapping"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addSecurityReference"
+               description="Add a new security role reference record to the set of records for this servlet."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Role name used within this servlet"
+                 type="java.lang.String"/>
+      <parameter name="link"
+                 description="Role name used within the web application"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="addValve"
+               description="Add a valve to this Wrapper"
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="valveType"
+                 description="Type(classname) of the new valve to be added"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findInitParameter"
+               description="Add a mapping associated with the Wrapper."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="mapping"
+                 description="The new wrapper mapping"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findInitParameters"
+               description="Return the names of all defined initialization parameters for this servlet."
+               impact="INFO"
+               returnType="[Ljava.lang.String;">
+    </operation>
 
     <operation name="findMappings"
                description="Return the mappings associated with this wrapper"
@@ -1054,23 +1756,66 @@
                returnType="org.apache.catalina.Wrapper">
     </operation>
     
-        <operation name="addLifecycleListener"
-               description="Add a lifecycle listener to this Context"
+    <operation name="findSecurityReference"
+               description="Return the security role link for the specified security role reference name."
+               impact="ACTION"
+               returnType="java.lang.String">
+      <parameter name="name"
+                 description="Security role reference used within this servle"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="findSecurityReferences"
+               description="Return the set of security role reference names associated with this servlet"
+               impact="INFO"
+               returnType="[Ljava.lang.String;">
+    </operation>
+    
+    <operation name="removeInitParameter"
+               description="Remove the specified initialization parameter from this servlet."
                impact="ACTION"
                returnType="void">
-      <parameter name="listener"
-                 description="New lifecycle listener to be added"
-                 type="org.apache.catalina.LifecycleListener"/>
+      <parameter name="name"
+                 description="Name of the initialization parameter to remove"
+                 type="java.lang.String"/>
     </operation>
     
-    <operation name="removeLifecycleListener"
-               description="Remove a lifecycle listener from this Context"
+    <operation name="removeLifecycleListeners"
+               description="Removes lifecycle listeners of given class type from this Wrapper"
                impact="ACTION"
                returnType="void">
       <parameter name="listener"
-                 description="New lifecycle listener to be removed"
-                 type="org.apache.catalina.LifecycleListener"/>
+                 description="Type(classname) of the lifecycle listeners to be removed"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="removeMapping"
+               description="Remove a mapping associated with the wrapper."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="mapping"
+                 description="The pattern to remove"
+                 type="java.lang.String"/>
+    </operation>
+    
+    <operation name="removeSecurityReference"
+               description="Remove any security role reference for the specified role name."
+               impact="ACTION"
+               returnType="void">
+      <parameter name="name"
+                 description="Security role used within this servlet to be removeds"
+                 type="java.lang.String"/>
     </operation>
+    
+    <operation name="removeValve"
+               description="Remove a valve from this Wrapper"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="valveName"
+                 description="Objectname of the valve to be removed"
+                 type="java.lang.String"/>
+    </operation>
+   
   </mbean>
   
   <mbean name="StandardWrapperValve"

Added: tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java?rev=996231&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java (added)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java Sun Sep 12 01:25:03 2010
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.mbeans;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.ContainerBase;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.HostConfig;
+import org.apache.catalina.util.LifecycleMBeanBase;
+import org.apache.catalina.valves.ValveBase;
+import org.apache.tomcat.util.modeler.BaseModelMBean;
+
+public class ContainerMBean extends BaseModelMBean {
+
+    /**
+     * Construct a <code>ModelMBean</code> with default
+     * <code>ModelMBeanInfo</code> information.
+     *
+     * @exception MBeanException if the initializer of an object
+     *  throws an exception
+     * @exception RuntimeOperationsException if an IllegalArgumentException
+     *  occurs
+     */
+    public ContainerMBean() 
+        throws MBeanException, RuntimeOperationsException {
+        
+        super();
+    }
+    
+    /**
+     * Add a new child Container to those associated with this Container,
+     * if supported. Won't start the child yet. Has to be started with a call to
+     * Start method after necessary configurations are done.
+     * 
+     * @param type ClassName of the child to be added
+     * @param name Name of the child to be added
+     * 
+     * @exception MBeanException if the child cannot be added
+     */
+    public void addChild(String type, String name) throws MBeanException{ 
+        Container contained = null;
+        try {
+            contained = (Container)Class.forName(type).newInstance();
+            contained.setName(name);
+            
+            if(contained instanceof StandardHost){
+                HostConfig config = new HostConfig();
+                contained.addLifecycleListener(config);
+            } else if(contained instanceof StandardContext){
+                ContextConfig config = new ContextConfig();
+                contained.addLifecycleListener(config);
+            }
+
+        } catch (InstantiationException e) {
+            throw new MBeanException(e);
+        } catch (IllegalAccessException e) {
+            throw new MBeanException(e);
+        } catch (ClassNotFoundException e) {
+            throw new MBeanException(e);
+        }
+        
+        boolean oldValue= true;
+        
+        ContainerBase container = null;
+        try {
+            container = (ContainerBase)getManagedResource();
+            oldValue = container.getStartChildren();
+            container.setStartChildren(false);
+            container.addChild(contained);
+            contained.init();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        } catch (LifecycleException e){
+            throw new MBeanException(e);
+        } finally {
+            if(container != null) {
+                container.setStartChildren(oldValue);
+            }
+        }
+    }
+    
+    /**
+     * Remove an existing child Container from association with this parent
+     * Container.
+     *
+     * @param name Name of the existing child Container to be removed
+     */
+    public void removeChild(String name) throws MBeanException{
+        if(name != null){
+            try {
+                Container container = (Container)getManagedResource();
+                Container contained = container.findChild(name);
+                container.removeChild(contained);
+            } catch (InstanceNotFoundException e) {
+                throw new MBeanException(e);
+            } catch (RuntimeOperationsException e) {
+                throw new MBeanException(e);
+            } catch (InvalidTargetObjectTypeException e) {
+                throw new MBeanException(e);
+            }
+        }
+    }
+    
+    /**
+     * Adds a valve to this Container instance.
+     *
+     * @param valveType ClassName of the valve to be added
+     * 
+     * @exception MBeanException if a component cannot be removed
+     */
+    public String addValve(String valveType) throws MBeanException{ 
+        Valve valve = null;
+        try {
+            valve = (Valve)Class.forName(valveType).newInstance();
+        } catch (InstantiationException e) {
+            throw new MBeanException(e);
+        } catch (IllegalAccessException e) {
+            throw new MBeanException(e);
+        } catch (ClassNotFoundException e) {
+            throw new MBeanException(e);
+        }
+        
+        if (valve == null) {
+            return null;
+        }
+            
+        try {
+            ContainerBase container = (ContainerBase)getManagedResource();
+            container.addValve(valve);
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        return ((LifecycleMBeanBase)valve).getObjectName().toString();
+    }
+    
+    /**
+     * Remove an existing Valve.
+     *
+     * @param name MBean Name of the component to remove
+     *
+     * @exception MBeanException if a component cannot be removed
+     */
+    public void removeValve(String valveName) throws MBeanException{
+        ContainerBase container=null;
+        try {
+            container = (ContainerBase)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        ObjectName oname;
+        try {
+            oname = new ObjectName(valveName);
+        } catch (MalformedObjectNameException e) {
+            throw new MBeanException(e);
+        } catch (NullPointerException e) {
+            throw new MBeanException(e);
+        }
+        
+        if(container != null){
+            Valve[] valves = container.getPipeline().getValves();
+            for (int i = 0; i < valves.length; i++) {
+                ObjectName voname = ((ValveBase) valves[i]).getObjectName();
+                if (voname.equals(oname)) {
+                    container.getPipeline().removeValve(valves[i]);
+                }
+            }
+        }
+    }
+    
+    /**
+     * Add a LifecycleEvent listener to this component.
+     *
+     * @param type ClassName of the listener to add
+     */
+    public void addLifeCycleListener(String type) throws MBeanException{
+        LifecycleListener listener = null;
+        try {
+            listener = (LifecycleListener)Class.forName(type).newInstance();
+        } catch (InstantiationException e) {
+            throw new MBeanException(e);
+        } catch (IllegalAccessException e) {
+            throw new MBeanException(e);
+        } catch (ClassNotFoundException e) {
+            throw new MBeanException(e);
+        }
+        
+        if(listener != null){
+            try {
+                ContainerBase container = (ContainerBase)getManagedResource();
+                container.addLifecycleListener(listener);
+            } catch (InstanceNotFoundException e) {
+                throw new MBeanException(e);
+            } catch (RuntimeOperationsException e) {
+                throw new MBeanException(e);
+            } catch (InvalidTargetObjectTypeException e) {
+                throw new MBeanException(e);
+            }
+        }
+    }
+    
+    /**
+     * Remove a LifecycleEvent listeners from this component.
+     *
+     * @param listener The ClassName of the listeners to be removed. 
+     * Note that all the listeners having given ClassName will be removed. 
+     */
+    public void removeLifeCycleListeners(String type) throws MBeanException{
+        ContainerBase container=null;
+        try {
+            container = (ContainerBase)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        LifecycleListener[] listeners = container.findLifecycleListeners();
+        for(LifecycleListener listener: listeners){
+            if(listener.getClass().equals(type)){
+                container.removeLifecycleListener(listener);
+            }
+        }
+    }
+
+}

Propchange: tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java?rev=996231&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java (added)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java Sun Sep 12 01:25:03 2010
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.mbeans;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.deploy.ApplicationParameter;
+import org.apache.catalina.deploy.ErrorPage;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
+import org.apache.catalina.deploy.SecurityConstraint;
+
+public class ContextMBean extends ContainerMBean {
+
+    public ContextMBean() throws MBeanException, RuntimeOperationsException {
+        
+        super();
+    }
+    
+     /**
+     * Return the set of application parameters for this application.
+     */
+    public String[] findApplicationParameters() throws MBeanException {
+        
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        ApplicationParameter[] params = context.findApplicationParameters();
+        String[] stringParams = new String[params.length];
+        for(int counter=0; counter < params.length; counter++){
+           stringParams[counter]=params[counter].toString();
+        }
+        
+        return stringParams;
+        
+    }
+    
+    /**
+     * Return the security constraints for this web application.
+     * If there are none, a zero-length array is returned.
+     */
+    public String[] findConstraints() throws MBeanException {
+
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        SecurityConstraint[] constraints = context.findConstraints();
+        String[] stringConstraints = new String[constraints.length];
+        for(int counter=0; counter < constraints.length; counter++){
+            stringConstraints[counter]=constraints[counter].toString();
+        }
+        
+        return stringConstraints;
+        
+    }
+    
+    /**
+     * Return the error page entry for the specified HTTP error code,
+     * if any; otherwise return <code>null</code>.
+     *
+     * @param errorCode Error code to look up
+     */
+    public String findErrorPage(int errorCode) throws MBeanException {
+
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        return context.findErrorPage(errorCode).toString();
+        
+    }
+    
+    /**
+     * Return the error page entry for the specified Java exception type,
+     * if any; otherwise return <code>null</code>.
+     *
+     * @param exceptionType Exception type to look up
+     */
+    public String findErrorPage(String exceptionType) throws MBeanException {
+
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        return context.findErrorPage(exceptionType).toString();
+        
+    }
+    
+    /**
+     * Return the set of defined error pages for all specified error codes
+     * and exception types.
+     */
+    public String[] findErrorPages() throws MBeanException {
+        
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        ErrorPage[] pages = context.findErrorPages();
+        String[] stringPages = new String[pages.length];
+        for(int counter=0; counter < pages.length; counter++){
+            stringPages[counter]=pages[counter].toString();
+        }
+        
+        return stringPages;
+        
+    }
+    
+    /**
+     * Return the filter definition for the specified filter name, if any;
+     * otherwise return <code>null</code>.
+     *
+     * @param filterName Filter name to look up
+     */
+    public String findFilterDef(String name) throws MBeanException {
+        
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        FilterDef filterDef = context.findFilterDef(name);
+        return filterDef.toString();
+        
+    }
+    
+    /**
+     * Return the set of defined filters for this Context.
+     */
+    public String[] findFilterDefs() throws MBeanException {
+        
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        ApplicationParameter[] params = context.findApplicationParameters();
+        String[] stringParams = new String[params.length];
+        for(int counter=0; counter < params.length; counter++){
+            stringParams[counter]=params[counter].toString();
+        }
+        
+        return stringParams;
+        
+    }
+    
+    /**
+     * Return the set of filter mappings for this Context.
+     */
+    public String[] findFilterMaps() throws MBeanException {
+        
+        Context context; 
+        try {
+            context = (Context)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        FilterMap[] maps = context.findFilterMaps();
+        String[] stringMaps = new String[maps.length];
+        for(int counter=0; counter < maps.length; counter++){
+            stringMaps[counter]=maps[counter].toString();
+        }
+        
+        return stringMaps;
+        
+    }
+
+}

Propchange: tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java?rev=996231&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java (added)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java Sun Sep 12 01:25:03 2010
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.mbeans;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+
+import org.apache.catalina.Executor;
+import org.apache.catalina.Service;
+import org.apache.catalina.connector.Connector;
+import org.apache.tomcat.util.modeler.BaseModelMBean;
+
+public class ServiceMBean extends BaseModelMBean {
+
+    public ServiceMBean() 
+        throws MBeanException, RuntimeOperationsException {
+        
+        super();
+        
+    }
+    
+    /**
+     * Add a new Connector to the set of defined Connectors, and associate it
+     * with this Service's Container.
+     *
+     * @param address The IP address on which to bind
+     * @param port TCP port number to listen on
+     * @param isAjp Create a AJP/1.3 Connector
+     * @param isSSL Create a secure Connector
+     * 
+     * @throws MBeanException 
+     */
+    public void addConnector(String address, int port, boolean isAjp, boolean isSSL) throws MBeanException {
+        
+        Service service; 
+        try {
+            service = (Service)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        Connector connector = new Connector();
+        if ((address!=null) && (address.length()>0)) {
+            connector.setProperty("address", address);
+        }
+        
+        connector.setPort(port);
+        connector.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
+        connector.setSecure(isSSL);
+        connector.setScheme(isSSL ? "https" : "http");
+
+        service.addConnector(connector);       
+
+    }
+    
+    /**
+     * Adds a named executor to the service
+     * @param type Classname of the Executor to be added
+     * @throws MBeanException 
+     */
+    public void addExecutor(String type) throws MBeanException {
+        
+        Service service; 
+        try {
+            service = (Service)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        Executor executor;
+        try {
+             executor = (Executor)Class.forName(type).newInstance();
+        } catch (InstantiationException e) {
+            throw new MBeanException(e);
+        } catch (IllegalAccessException e) {
+            throw new MBeanException(e);
+        } catch (ClassNotFoundException e) {
+            throw new MBeanException(e);
+        }
+        
+        service.addExecutor(executor);
+        
+    }
+    
+    /**
+     * Find and return the set of Connectors associated with this Service.
+     * @throws MBeanException 
+     */
+    public String[] findConnectors() throws MBeanException {
+        
+        Service service; 
+        try {
+            service = (Service)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        Connector[] connectors = service.findConnectors(); 
+        String[] str = new String[connectors.length];
+        
+        for(int i=0; i< connectors.length; i++){
+            str[i] = connectors[i].toString();
+        }
+        
+        return str;
+
+    }
+    
+    /**
+     * Retrieves all executors
+     * @throws MBeanException 
+     */
+    public String[] findExecutors() throws MBeanException {
+
+        Service service; 
+        try {
+            service = (Service)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        Executor[] executors = service.findExecutors();
+        String[] str = new String[executors.length];
+        
+        for(int i=0; i< executors.length; i++){
+            str[i] = executors[i].toString();
+        }
+        
+        return str;
+    }
+    
+    /**
+     * Retrieves executor by name
+     * @param name Name of the executor to be retrieved
+     * @throws MBeanException 
+     */
+    public String getExecutor(String name) throws MBeanException{
+       
+        Service service; 
+        try {
+            service = (Service)getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (RuntimeOperationsException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+        
+        Executor executor = service.getExecutor(name);
+        return executor.toString();
+        
+    }
+
+}

Propchange: tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/catalina/startup/Catalina.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Catalina.java?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Catalina.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Catalina.java Sun Sep 12 01:25:03 2010
@@ -174,11 +174,12 @@ public class Catalina {
      * @param parentClassLoader The shared extensions class loader.
      */
     public void setParentClassLoader(ClassLoader parentClassLoader) {
-
         this.parentClassLoader = parentClassLoader;
-
     }
 
+    public ClassLoader getParentClassLoader() {
+        return parentClassLoader;
+    }
 
     public void setServer(Server server) {
         this.server = server;
@@ -528,6 +529,8 @@ public class Catalina {
             return;
         }
 
+        getServer().setCatalina(this);
+
         // Stream redirection
         initStreams();
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=996231&r1=996230&r2=996231&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sun Sep 12 01:25:03 2010
@@ -135,6 +135,12 @@
         Ensure that Context elements defined in server.xml use any configClass
         setting specified in the parent Host element. (markt)
       </fix>
+      <fix>
+        GSOC 2010. Enable the creation of Services, Engines, Connectors, Hosts
+        and Contexts via JMX from a minimal server.xml that contains only a
+        Server element. Based on a patch by Chamith Buddhika. (markt)
+      </fix>
+      
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Mime
View raw message