import org.apache.catalina.valves.RemoteAddrValve;
import org.apache.catalina.valves.RemoteHostValve;
import org.apache.catalina.valves.ValveBase;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
/**
* @version $Revision$ $Date$
*/
-public class MBeanFactory extends BaseModelMBean {
+public class MBeanFactory {
private static final org.apache.juli.logging.Log log =
org.apache.juli.logging.LogFactory.getLog(MBeanFactory.class);
String docBase)
throws Exception {
- // XXX for backward compatibility. Remove it once supported by the admin
- return
- createStandardContext(parent,path,docBase,false,false,false,false);
+ return createStandardContext(parent, path, docBase, false, false,
+ false, false);
}
/**
/**
+ * Creates a new StandardService and StandardEngine.
+ *
+ * @param domain Domain name for the container instance
+ * @param defaultHost Name of the default host to be used in the Engine
+ * @param baseDir Base directory value for Engine
+ *
+ * @exception Exception if an MBean cannot be created or registered
+ */
+ public String createStandardServiceEngine(String domain,
+ String defaultHost, String baseDir) throws Exception{
+
+ if (!(container instanceof Server)) {
+ throw new Exception();
+ }
+
+ StandardEngine engine = new StandardEngine();
+ engine.setDomain(domain);
+ engine.setName(domain);
+ engine.setDefaultHost(defaultHost);
+ engine.setBaseDir(baseDir);
+
+ Service service = new StandardService();
+ service.setContainer(engine);
+ service.setName(domain);
+
+ ((Server) container).addService(service);
+
+ return engine.getJmxName().toString();
+ }
+
+
+ /**
* Create a new StandardManager.
*
* @param parent MBean Name of the associated parent component
/**
+ * Remove an existing Service.
+ *
+ * @param name MBean Name of the component to remove
+ *
+ * @exception Exception if a component cannot be removed
+ */
+ public void removeService(String name) throws Exception {
+
+ if (!(container instanceof Server)) {
+ throw new Exception();
+ }
+
+ // Acquire a reference to the component to be removed
+ ObjectName oname = new ObjectName(name);
+ Service service = getService(oname);
+ ((Server) container).removeService(service);
+ }
+
+
+ /**
* Remove an existing Valve.
*
* @param name MBean Name of the component to remove
<mbeans-descriptors>
<mbean name="MBeanFactory"
- className="org.apache.catalina.mbeans.MBeanFactory"
+ type="org.apache.catalina.mbeans.MBeanFactory"
description="Factory for MBeans and corresponding components"
domain="Catalina">
type="java.lang.String"/>
</operation>
- <operation name="createFileLogger"
- description="Create a new FileLogger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
<operation name="createHttpConnector"
description="Create a new HttpConnector"
impact="ACTION"
type="java.lang.String"/>
</operation>
- <operation name="createStandardEngine"
- description="Create a new StandardEngine"
+ <operation name="createStandardServiceEngine"
+ description="Create a new StandardService and StandardEngine"
impact="ACTION"
returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="name"
- description="Unique name of this Engine"
- type="java.lang.String"/>
- <parameter name="defaultHost"
- description="Default host name for this Engine"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardEngineService"
- description="Create a new StandardEngine and StandardService"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent Service"
- type="java.lang.String"/>
- <parameter name="engineName"
- description="Unique name of this Engine"
+ <parameter name="domain"
+ description="Domain used for MBeans associated with the new Service"
type="java.lang.String"/>
<parameter name="defaultHost"
- description="Default host name for this Engine"
+ description="Default host name for the new Engine"
type="java.lang.String"/>
- <parameter name="serviceName"
- description="Unique name of this Service"
+ <parameter name="baseDir"
+ description="Base directory value for the new Engine"
type="java.lang.String"/>
</operation>
type="java.lang.String"/>
</operation>
- <operation name="createStandardService"
- description="Create a new StandardService"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="name"
- description="Unique name of this Service"
- type="java.lang.String"/>
- <parameter name="domain"
- description="The domain of this Service"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createSystemErrLogger"
- description="Create a new System Error Logger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createSystemOutLogger"
- description="Create a new System Output Logger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
<operation name="createUserDatabaseRealm"
description="Create a new UserDatabase Realm"
impact="ACTION"
type="java.lang.String"/>
</operation>
- <operation name="removeLogger"
- description="Remove an existing Logger"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
<operation name="removeManager"
description="Remove an existing Manager"
impact="ACTION"