FileDocCategorySizeDatePackage
StandardContextMBean.javaAPI DocApache Tomcat 6.0.1412194Fri Jul 20 04:20:34 BST 2007org.apache.catalina.mbeans

StandardContextMBean

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

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

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

Fields Summary
protected org.apache.tomcat.util.modeler.Registry
registry
The configuration information registry for our managed beans.
protected org.apache.tomcat.util.modeler.ManagedBean
managed
The ManagedBean information describing this MBean.
Constructors Summary
public StandardContextMBean()
Construct a ModelMBean with default ModelMBeanInfo information.

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


        super();

    
Methods Summary
public java.lang.StringaddEnvironment(java.lang.String envName, java.lang.String type)
Add an environment entry for this web application.

param
envName New environment entry name


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextEnvironment env = nresources.findEnvironment(envName);
        if (env != null) {
            throw new IllegalArgumentException
                ("Invalid environment name - already exists '" + envName + "'");
        }
        env = new ContextEnvironment();
        env.setName(envName);
        env.setType(type);
        nresources.addEnvironment(env);
        
        // Return the corresponding MBean name
        ManagedBean managed = registry.findManagedBean("ContextEnvironment");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), env);
        return (oname.toString());
        
    
public java.lang.StringaddResource(java.lang.String resourceName, java.lang.String type)
Add a resource reference for this web application.

param
resourceName New resource reference name

        
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextResource resource = nresources.findResource(resourceName);
        if (resource != null) {
            throw new IllegalArgumentException
                ("Invalid resource name - already exists'" + resourceName + "'");
        }
        resource = new ContextResource();
        resource.setName(resourceName);
        resource.setType(type);
        nresources.addResource(resource);
        
        // Return the corresponding MBean name
        ManagedBean managed = registry.findManagedBean("ContextResource");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), resource);
        return (oname.toString());
    
public java.lang.StringaddResourceLink(java.lang.String resourceLinkName, java.lang.String global, java.lang.String name, java.lang.String type)
Add a resource link for this web application.

param
resourceLinkName New resource link name

        
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return null;
        }
        ContextResourceLink resourceLink = 
                                nresources.findResourceLink(resourceLinkName);
        if (resourceLink != null) {
            throw new IllegalArgumentException
                ("Invalid resource link name - already exists'" + 
                                                        resourceLinkName + "'");
        }
        resourceLink = new ContextResourceLink();
        resourceLink.setGlobal(global);
        resourceLink.setName(resourceLinkName);
        resourceLink.setType(type);
        nresources.addResourceLink(resourceLink);
        
        // Return the corresponding MBean name
        ManagedBean managed = registry.findManagedBean("ContextResourceLink");
        ObjectName oname =
            MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
        return (oname.toString());
    
public java.lang.String[]getEnvironments()
Return the MBean Names of the set of defined environment entries for this web application

        ContextEnvironment[] envs = getNamingResources().findEnvironments();
        ArrayList results = new ArrayList();
        for (int i = 0; i < envs.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for environment " + envs[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
private org.apache.catalina.deploy.NamingResourcesgetNamingResources()
Return the naming resources associated with this web application.


    
    // ------------------------------------------------------------- Attributes

    
                  
       
        
        return ((StandardContext)this.resource).getNamingResources();
    
    
public java.lang.String[]getResourceLinks()
Return the MBean Names of all the defined resource links for this application

        
        ContextResourceLink[] links = getNamingResources().findResourceLinks();
        ArrayList results = new ArrayList();
        for (int i = 0; i < links.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(managed.getDomain(), links[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for resource " + links[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public java.lang.String[]getResources()
Return the MBean Names of all the defined resource references for this application.

        
        ContextResource[] resources = getNamingResources().findResources();
        ArrayList results = new ArrayList();
        for (int i = 0; i < resources.length; i++) {
            try {
                ObjectName oname =
                    MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for resource " + resources[i]);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public javax.naming.directory.DirContextgetStaticResources()
Return the naming resources associated with this web application.


        return ((StandardContext)this.resource).getResources();

    
public java.lang.String[]getWelcomeFiles()
Return the naming resources associated with this web application.


        return ((StandardContext)this.resource).findWelcomeFiles();

    
public voidreload()
Return the naming resources associated with this web application.

        
        ((StandardContext)this.resource).reload();
    
    
public voidremoveEnvironment(java.lang.String envName)
Remove any environment entry with the specified name.

param
envName Name of the environment entry to remove


        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextEnvironment env = nresources.findEnvironment(envName);
        if (env == null) {
            throw new IllegalArgumentException
                ("Invalid environment name '" + envName + "'");
        }
        nresources.removeEnvironment(envName);

    
public voidremoveResource(java.lang.String resourceName)
Remove any resource reference with the specified name.

param
resourceName Name of the resource reference to remove


        resourceName = ObjectName.unquote(resourceName);
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextResource resource = nresources.findResource(resourceName);
        if (resource == null) {
            throw new IllegalArgumentException
                ("Invalid resource name '" + resourceName + "'");
        }
        nresources.removeResource(resourceName);
    
public voidremoveResourceLink(java.lang.String resourceLinkName)
Remove any resource link with the specified name.

param
resourceLinkName Name of the resource reference to remove


        resourceLinkName = ObjectName.unquote(resourceLinkName);
        NamingResources nresources = getNamingResources();
        if (nresources == null) {
            return;
        }
        ContextResourceLink resource = nresources.findResourceLink(resourceLinkName);
        if (resource == null) {
            throw new IllegalArgumentException
                ("Invalid resource name '" + resourceLinkName + "'");
        }
        nresources.removeResourceLink(resourceLinkName);