FileDocCategorySizeDatePackage
MBeanFactory.javaAPI DocApache Tomcat 6.0.1438319Fri Jul 20 04:20:36 BST 2007org.apache.catalina.mbeans

MBeanFactory

public class MBeanFactory extends org.apache.tomcat.util.modeler.BaseModelMBean

A ModelMBean implementation for the org.apache.catalina.core.StandardServer component.

author
Amy Roh
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
private static org.apache.juli.logging.Log
log
private static MBeanServer
mserver
The MBeanServer for this application.
private static org.apache.tomcat.util.modeler.Registry
registry
The configuration information registry for our managed beans.
Constructors Summary
public MBeanFactory()
Construct a ModelMBean with default ModelMBeanInfo information.

exception
MBeanException if the initializer of an object throws an exception
exception
RuntimeOperationsException if an IllegalArgumentException occurs



    // ----------------------------------------------------------- Constructors


                                   
     
           

        super();

    
Methods Summary
public java.lang.StringcreateAccessLoggerValve(java.lang.String parent)
Create a new AccessLoggerValve.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        ObjectName pname = new ObjectName(parent);
        // Create a new AccessLogValve instance
        AccessLogValve accessLogger = new AccessLogValve();
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.addValve(accessLogger);
        ObjectName oname = accessLogger.getObjectName();
        return (oname.toString());

    
public java.lang.StringcreateAjpConnector(java.lang.String parent, java.lang.String address, int port)
Create a new AjpConnector

param
parent MBean Name of the associated parent component
param
address The IP address on which to bind
param
port TCP port number to listen on
exception
Exception if an MBean cannot be created or registered


        return createConnector(parent, address, port, true, false);
    
private java.lang.StringcreateConnector(java.lang.String parent, java.lang.String address, int port, boolean isAjp, boolean isSSL)
Create a new Connector

param
parent MBean Name of the associated parent component
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
exception
Exception if an MBean cannot be created or registered

        Connector retobj = new Connector();
        if ((address!=null) && (address.length()>0)) {
            retobj.setProperty("address", address);
        }
        // Set port number
        retobj.setPort(port);
        // Set the protocol
        retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
        // Set SSL
        retobj.setSecure(isSSL);
        retobj.setScheme(isSSL ? "https" : "http");
        // Add the new instance to its parent component
        // FIX ME - addConnector will fail
        ObjectName pname = new ObjectName(parent);
        Service service = getService(pname);
        service.addConnector(retobj);
        
        // Return the corresponding MBean name
        ObjectName coname = retobj.getObjectName();
        
        return (coname.toString());
    
public java.lang.StringcreateDataSourceRealm(java.lang.String parent, java.lang.String dataSourceName, java.lang.String roleNameCol, java.lang.String userCredCol, java.lang.String userNameCol, java.lang.String userRoleTable, java.lang.String userTable)
Create a new DataSource Realm.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new DataSourceRealm instance
        DataSourceRealm realm = new DataSourceRealm();
        realm.setDataSourceName(dataSourceName);
        realm.setRoleNameCol(roleNameCol);
        realm.setUserCredCol(userCredCol);
        realm.setUserNameCol(userNameCol);
        realm.setUserRoleTable(userRoleTable);
        realm.setUserTable(userTable);

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.setRealm(realm);
        // Return the corresponding MBean name
        ObjectName oname = realm.getObjectName();
        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }   

    
public java.lang.StringcreateHttpConnector(java.lang.String parent, java.lang.String address, int port)
Create a new HttpConnector

param
parent MBean Name of the associated parent component
param
address The IP address on which to bind
param
port TCP port number to listen on
exception
Exception if an MBean cannot be created or registered

	return createConnector(parent, address, port, false, false);
    
public java.lang.StringcreateHttpsConnector(java.lang.String parent, java.lang.String address, int port)
Create a new HttpsConnector

param
parent MBean Name of the associated parent component
param
address The IP address on which to bind
param
port TCP port number to listen on
exception
Exception if an MBean cannot be created or registered

        return createConnector(parent, address, port, false, true);
    
public java.lang.StringcreateJDBCRealm(java.lang.String parent, java.lang.String driverName, java.lang.String connectionName, java.lang.String connectionPassword, java.lang.String connectionURL)
Create a new JDBC Realm.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new JDBCRealm instance
        JDBCRealm realm = new JDBCRealm();
        realm.setDriverName(driverName);
        realm.setConnectionName(connectionName);
        realm.setConnectionPassword(connectionPassword);
        realm.setConnectionURL(connectionURL);

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.setRealm(realm);
        // Return the corresponding MBean name
        ObjectName oname = realm.getObjectName();

        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }   

    
public java.lang.StringcreateJNDIRealm(java.lang.String parent)
Create a new JNDI Realm.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


         // Create a new JNDIRealm instance
        JNDIRealm realm = new JNDIRealm();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.setRealm(realm);
        // Return the corresponding MBean name
        ObjectName oname = realm.getObjectName();

        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }   


    
public java.lang.StringcreateMemoryRealm(java.lang.String parent)
Create a new Memory Realm.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


         // Create a new MemoryRealm instance
        MemoryRealm realm = new MemoryRealm();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.setRealm(realm);
        // Return the corresponding MBean name
        ObjectName oname = realm.getObjectName();
        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }   

    
public java.lang.StringcreateRemoteAddrValve(java.lang.String parent)
Create a new Remote Address Filter Valve.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new RemoteAddrValve instance
        RemoteAddrValve valve = new RemoteAddrValve();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        containerBase.addValve(valve);
        ObjectName oname = valve.getObjectName();
        return (oname.toString());

    
public java.lang.StringcreateRemoteHostValve(java.lang.String parent)
Create a new Remote Host Filter Valve.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new RemoteHostValve instance
        RemoteHostValve valve = new RemoteHostValve();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        containerBase.addValve(valve);
        ObjectName oname = valve.getObjectName();
        return (oname.toString());
        
    
public java.lang.StringcreateRequestDumperValve(java.lang.String parent)
Create a new Request Dumper Valve.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new RequestDumperValve instance
        RequestDumperValve valve = new RequestDumperValve();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        containerBase.addValve(valve);
        ObjectName oname = valve.getObjectName();
        return (oname.toString());

    
public java.lang.StringcreateSingleSignOn(java.lang.String parent)
Create a new Single Sign On Valve.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new SingleSignOn instance
        SingleSignOn valve = new SingleSignOn();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        containerBase.addValve(valve);
        ObjectName oname = valve.getObjectName();
        return (oname.toString());

    
public java.lang.StringcreateStandardContext(java.lang.String parent, java.lang.String path, java.lang.String docBase)
Create a new StandardContext.

param
parent MBean Name of the associated parent component
param
path The context path for this Context
param
docBase Document base directory (or WAR) for this Context
exception
Exception if an MBean cannot be created or registered

                                            
        // XXX for backward compatibility. Remove it once supported by the admin
        return 
            createStandardContext(parent,path,docBase,false,false,false,false);                                  
    
public java.lang.StringcreateStandardContext(java.lang.String parent, java.lang.String path, java.lang.String docBase, boolean xmlValidation, boolean xmlNamespaceAware, boolean tldValidation, boolean tldNamespaceAware)
Create a new StandardContext.

param
parent MBean Name of the associated parent component
param
path The context path for this Context
param
docBase Document base directory (or WAR) for this Context
exception
Exception if an MBean cannot be created or registered


        // Create a new StandardContext instance
        StandardContext context = new StandardContext();
        path = getPathStr(path);
        context.setPath(path);
        context.setDocBase(docBase);
        context.setXmlValidation(xmlValidation);
        context.setXmlNamespaceAware(xmlNamespaceAware);
        context.setTldValidation(tldValidation);
        context.setTldNamespaceAware(tldNamespaceAware);
        
        ContextConfig contextConfig = new ContextConfig();
        context.addLifecycleListener(contextConfig);

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ObjectName deployer = new ObjectName(pname.getDomain()+
                                             ":type=Deployer,host="+
                                             pname.getKeyProperty("host"));
        if(mserver.isRegistered(deployer)) {
            String contextPath = context.getPath();
            mserver.invoke(deployer, "addServiced",
                           new Object [] {contextPath},
                           new String [] {"java.lang.String"});
            String configPath = (String)mserver.getAttribute(deployer,
                                                             "configBaseName");
            String baseName = getConfigFile(contextPath);
            File configFile = new File(new File(configPath), baseName+".xml");
            context.setConfigFile(configFile.getAbsolutePath());
            mserver.invoke(deployer, "manageApp",
                           new Object[] {context},
                           new String[] {"org.apache.catalina.Context"});
            mserver.invoke(deployer, "removeServiced",
                           new Object [] {contextPath},
                           new String [] {"java.lang.String"});
        } else {
            log.warn("Deployer not found for "+pname.getKeyProperty("host"));
            Service service = getService(pname);
            Engine engine = (Engine) service.getContainer();
            Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
            host.addChild(context);
        }

        // Return the corresponding MBean name
        ObjectName oname = context.getJmxName();

        return (oname.toString());

    
public java.util.VectorcreateStandardEngineService(java.lang.String parent, java.lang.String engineName, java.lang.String defaultHost, java.lang.String serviceName)
Create a new StandardEngine.

param
parent MBean Name of the associated parent component
param
engineName Unique name of this Engine
param
defaultHost Default hostname of this Engine
param
serviceName Unique name of this Service
exception
Exception if an MBean cannot be created or registered


        // Create a new StandardService instance
        StandardService service = new StandardService();
        service.setName(serviceName);
        // Create a new StandardEngine instance
        StandardEngine engine = new StandardEngine();
        engine.setName(engineName);
        engine.setDefaultHost(defaultHost);
        // Need to set engine before adding it to server in order to set domain
        service.setContainer(engine);
        // Add the new instance to its parent component
        Server server = ServerFactory.getServer();
        server.addService(service);
        Vector onames = new Vector();
        // FIXME service & engine.getObjectName
        //ObjectName oname = engine.getObjectName();
        ObjectName oname = 
            MBeanUtils.createObjectName(engineName, engine);
        onames.add(0, oname);
        //oname = service.getObjectName();
        oname = 
            MBeanUtils.createObjectName(engineName, service);
        onames.add(1, oname);
        return (onames);

    
public java.lang.StringcreateStandardHost(java.lang.String parent, java.lang.String name, java.lang.String appBase, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs, boolean xmlNamespaceAware, boolean xmlValidation)
Create a new StandardHost.

param
parent MBean Name of the associated parent component
param
name Unique name of this Host
param
appBase Application base directory name
param
autoDeploy Should we auto deploy?
param
deployOnStartup Deploy on server startup?
param
deployXML Should we deploy Context XML config files property?
param
unpackWARs Should we unpack WARs when auto deploying?
param
xmlNamespaceAware Should we turn on/off XML namespace awareness?
param
xmlValidation Should we turn on/off XML validation?
exception
Exception if an MBean cannot be created or registered


        // Create a new StandardHost instance
        StandardHost host = new StandardHost();
        host.setName(name);
        host.setAppBase(appBase);
        host.setAutoDeploy(autoDeploy);
        host.setDeployOnStartup(deployOnStartup);
        host.setDeployXML(deployXML);
        host.setUnpackWARs(unpackWARs);
        host.setXmlNamespaceAware(xmlNamespaceAware);
        host.setXmlValidation(xmlValidation);
	
        // add HostConfig for active reloading
        HostConfig hostConfig = new HostConfig();
        host.addLifecycleListener(hostConfig);

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        engine.addChild(host);

        // Return the corresponding MBean name
        return (host.getObjectName().toString());

    
public java.lang.StringcreateStandardManager(java.lang.String parent)
Create a new StandardManager.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new StandardManager instance
        StandardManager manager = new StandardManager();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        if (containerBase != null) {
            containerBase.setManager(manager);
        } 
        ObjectName oname = manager.getObjectName();
        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }
        
    
public java.lang.StringcreateStandardService(java.lang.String parent, java.lang.String name, java.lang.String domain)
Create a new StandardService.

param
parent MBean Name of the associated parent component
param
name Unique name of this StandardService
exception
Exception if an MBean cannot be created or registered


        // Create a new StandardService instance
        StandardService service = new StandardService();
        service.setName(name);

        // Add the new instance to its parent component
        Server server = ServerFactory.getServer();
        server.addService(service);

        // Return the corresponding MBean name
        return (service.getObjectName().toString());

    
public java.lang.StringcreateUserDatabaseRealm(java.lang.String parent, java.lang.String resourceName)
Create a new UserDatabaseRealm.

param
parent MBean Name of the associated parent component
param
resourceName Global JNDI resource name of the associated UserDatabase
exception
Exception if an MBean cannot be created or registered


         // Create a new UserDatabaseRealm instance
        UserDatabaseRealm realm = new UserDatabaseRealm();
        realm.setResourceName(resourceName);
        
        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        // Add the new instance to its parent component
        containerBase.setRealm(realm);
        // Return the corresponding MBean name
        ObjectName oname = realm.getObjectName();
        // FIXME getObjectName() returns null
        //ObjectName oname = 
        //    MBeanUtils.createObjectName(pname.getDomain(), realm);
        if (oname != null) {
            return (oname.toString());
        } else {
            return null;
        }   

    
public java.lang.StringcreateWebappLoader(java.lang.String parent)
Create a new Web Application Loader.

param
parent MBean Name of the associated parent component
exception
Exception if an MBean cannot be created or registered


        // Create a new WebappLoader instance
        WebappLoader loader = new WebappLoader();

        // Add the new instance to its parent component
        ObjectName pname = new ObjectName(parent);
        ContainerBase containerBase = getParentContainerFromParent(pname);
        if (containerBase != null) {
            containerBase.setLoader(loader);
        } 
        // FIXME add Loader.getObjectName
        //ObjectName oname = loader.getObjectName();
        ObjectName oname = 
            MBeanUtils.createObjectName(pname.getDomain(), loader);
        return (oname.toString());
        
    
public java.lang.StringfindObjectName(java.lang.String type)
Return the managed bean definition for the specified bean type

param
type MBean type


        if (type.equals("org.apache.catalina.core.StandardContext")) {
            return "StandardContext";
        } else if (type.equals("org.apache.catalina.core.StandardEngine")) {
            return "Engine";
        } else if (type.equals("org.apache.catalina.core.StandardHost")) {
            return "Host";
        } else {
            return null;
        }

    
private java.lang.StringgetConfigFile(java.lang.String path)
Given a context path, get the config file name.

        String basename = null;
        if (path.equals("")) {
            basename = "ROOT";
        } else {
            basename = path.substring(1).replace('/", '#");
        }
        return (basename);
    
private org.apache.catalina.core.ContainerBasegetParentContainerFromChild(javax.management.ObjectName oname)
Get Parent ContainerBase to add its child component from child component's ObjectName as a String

        
        String hostName = oname.getKeyProperty("host");
        String path = oname.getKeyProperty("path");
        Service service = getService(oname);
        StandardEngine engine = (StandardEngine) service.getContainer();
        if (hostName == null) {             
            // child's container is Engine
            return engine;
        } else if (path == null) {      
            // child's container is Host
            StandardHost host = (StandardHost) engine.findChild(hostName);
            return host;
        } else {                
            // child's container is Context
            StandardHost host = (StandardHost) engine.findChild(hostName);
            path = getPathStr(path);
            StandardContext context = (StandardContext) host.findChild(path);
            return context;
        }
    
private org.apache.catalina.core.ContainerBasegetParentContainerFromParent(javax.management.ObjectName pname)
Get Parent ContainerBase to add its child component from parent's ObjectName

        
        String type = pname.getKeyProperty("type");
        String j2eeType = pname.getKeyProperty("j2eeType");
        Service service = getService(pname);
        StandardEngine engine = (StandardEngine) service.getContainer();
        if ((j2eeType!=null) && (j2eeType.equals("WebModule"))) {
            String name = pname.getKeyProperty("name");
            name = name.substring(2);
            int i = name.indexOf("/");
            String hostName = name.substring(0,i);
            String path = name.substring(i);
            Host host = (Host) engine.findChild(hostName);
            String pathStr = getPathStr(path);
            StandardContext context = (StandardContext)host.findChild(pathStr);
            return context;
        } else if (type != null) {
            if (type.equals("Engine")) {
                return engine;
            } else if (type.equals("Host")) {
                String hostName = pname.getKeyProperty("host");
                StandardHost host = (StandardHost) engine.findChild(hostName);
                return host;
            }
        }
        return null;
        
    
private final java.lang.StringgetPathStr(java.lang.String t)
Little convenience method to remove redundant code when retrieving the path string

param
t path string
return
empty string if t==null || t.equals("/")

        if (t == null || t.equals("/")) {
            return "";
        }
        return t;
    
private org.apache.catalina.ServicegetService(javax.management.ObjectName oname)

    
        String domain = oname.getDomain();
        Server server = ServerFactory.getServer();
        Service[] services = server.findServices();
        StandardService service = null;
        for (int i = 0; i < services.length; i++) {
            service = (StandardService) services[i];
            if (domain.equals(service.getObjectName().getDomain())) {
                break;
            }
        }
        if (!service.getObjectName().getDomain().equals(domain)) {
            throw new Exception("Service with the domain is not found");
        }        
        return service;

    
public voidremoveConnector(java.lang.String name)
Remove an existing Connector.

param
name MBean Name of the component to remove
exception
Exception if a component cannot be removed


        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(name);
        Server server = ServerFactory.getServer();
        Service service = getService(oname);
        String port = oname.getKeyProperty("port");
        //String address = oname.getKeyProperty("address");

        Connector conns[] = (Connector[]) service.findConnectors();

        for (int i = 0; i < conns.length; i++) {
            String connAddress = String.valueOf(conns[i].getProperty("address"));
            String connPort = ""+conns[i].getPort();

            // if (((address.equals("null")) &&
            if ((connAddress==null) && port.equals(connPort)) {
                service.removeConnector(conns[i]);
                conns[i].destroy();
                break;
            }
            // } else if (address.equals(connAddress))
            if (port.equals(connPort)) {
                // Remove this component from its parent component
                service.removeConnector(conns[i]);
                conns[i].destroy();
                break;
            }
        }

    
public voidremoveContext(java.lang.String contextName)
Remove an existing Context.

param
contextName MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(contextName);
        String domain = oname.getDomain();
        StandardService service = (StandardService) getService(oname);

        Engine engine = (Engine) service.getContainer();
        String name = oname.getKeyProperty("name");
        name = name.substring(2);
        int i = name.indexOf("/");
        String hostName = name.substring(0,i);
        String path = name.substring(i);
        ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+
                                             hostName);
        String pathStr = getPathStr(path);
        if(mserver.isRegistered(deployer)) {
            mserver.invoke(deployer,"addServiced",
                           new Object[]{pathStr},
                           new String[] {"java.lang.String"});
            mserver.invoke(deployer,"unmanageApp",
                           new Object[] {pathStr},
                           new String[] {"java.lang.String"});
            mserver.invoke(deployer,"removeServiced",
                           new Object[] {pathStr},
                           new String[] {"java.lang.String"});
        } else {
            log.warn("Deployer not found for "+hostName);
            Host host = (Host) engine.findChild(hostName);
            Context context = (Context) host.findChild(pathStr);
            // Remove this component from its parent component
            host.removeChild(context);
            if(context instanceof StandardContext)
            try {
                ((StandardContext)context).destroy();
            } catch (Exception e) {
                log.warn("Error during context [" + context.getName() + "] destroy ", e);
           }
   
        }

    
public voidremoveHost(java.lang.String name)
Remove an existing Host.

param
name MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(name);
        String hostName = oname.getKeyProperty("host");
        Service service = getService(oname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(hostName);

        // Remove this component from its parent component
        if(host!=null) {
            if(host instanceof StandardHost)
                ((StandardHost)host).destroy();
            else
                engine.removeChild(host);
        }

    
public voidremoveLoader(java.lang.String name)
Remove an existing Loader.

param
name MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        ObjectName oname = new ObjectName(name);
        // Acquire a reference to the component to be removed
        ContainerBase container = getParentContainerFromChild(oname);    
        container.setLoader(null);
        
    
public voidremoveManager(java.lang.String name)
Remove an existing Manager.

param
name MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        ObjectName oname = new ObjectName(name);
        // Acquire a reference to the component to be removed
        ContainerBase container = getParentContainerFromChild(oname);    
        container.setManager(null);

    
public voidremoveRealm(java.lang.String name)
Remove an existing Realm.

param
name MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        ObjectName oname = new ObjectName(name);
        // Acquire a reference to the component to be removed
        ContainerBase container = getParentContainerFromChild(oname); 
        container.setRealm(null);
    
public voidremoveService(java.lang.String name)
Remove an existing Service.

param
name MBean Name of the component to remove
exception
Exception if a component cannot be removed


        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(name);
        String serviceName = oname.getKeyProperty("serviceName");
        Server server = ServerFactory.getServer();
        Service service = server.findService(serviceName);

        // Remove this component from its parent component
        server.removeService(service);

    
public voidremoveValve(java.lang.String name)
Remove an existing Valve.

param
name MBean Name of the comonent to remove
exception
Exception if a component cannot be removed


        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(name);
        ContainerBase container = getParentContainerFromChild(oname);
        String sequence = oname.getKeyProperty("seq");
        Valve[] valves = (Valve[])container.getValves();
        for (int i = 0; i < valves.length; i++) {
            ObjectName voname = ((ValveBase) valves[i]).getObjectName();
            if (voname.equals(oname)) {
                container.removeValve(valves[i]);
            }
        }