Search in sources :

Example 21 with NamingResources

use of org.apache.catalina.deploy.NamingResources in project Payara by payara.

the class StandardContext method addEnvironment.

// ------------------------------------------------------------- Operations
/**
 * Add an environment entry for this web application.
 *
 * @param envName New environment entry name
 */
public String addEnvironment(String envName, String type) throws MalformedObjectNameException {
    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
    return createObjectName(env).toString();
}
Also used : ContextEnvironment(org.apache.catalina.deploy.ContextEnvironment) NamingResources(org.apache.catalina.deploy.NamingResources)

Example 22 with NamingResources

use of org.apache.catalina.deploy.NamingResources in project Payara by payara.

the class StandardContext method addResourceLink.

/**
 * Add a resource link for this web application.
 *
 * @param resourceLinkName New resource link name
 */
public String addResourceLink(String resourceLinkName, String global, String name, String type) throws MalformedObjectNameException {
    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
    return createObjectName(resourceLink).toString();
}
Also used : ContextResourceLink(org.apache.catalina.deploy.ContextResourceLink) NamingResources(org.apache.catalina.deploy.NamingResources)

Aggregations

NamingResources (org.apache.catalina.deploy.NamingResources)22 ObjectName (javax.management.ObjectName)6 ContextEnvironment (org.apache.catalina.deploy.ContextEnvironment)6 ContextResource (org.apache.catalina.deploy.ContextResource)6 ContextResourceLink (org.apache.catalina.deploy.ContextResourceLink)6 ArrayList (java.util.ArrayList)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)3 MBeanException (javax.management.MBeanException)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)3 ManagedBean (org.apache.tomcat.util.modeler.ManagedBean)3 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 NamingException (javax.naming.NamingException)2 Context (org.apache.catalina.Context)2 LifecycleException (org.apache.catalina.LifecycleException)2 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1