Search in sources :

Example 1 with ContextEnvironment

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

the class StandardContext method removeEnvironment.

/**
 * Remove any environment entry with the specified name.
 *
 * @param name Name of the environment entry to remove
 */
@Override
public void removeEnvironment(String name) {
    if (namingResources == null) {
        return;
    }
    ContextEnvironment env = namingResources.findEnvironment(name);
    if (env == null) {
        throw new IllegalArgumentException("Invalid environment name '" + name + "'");
    }
    namingResources.removeEnvironment(name);
    if (notifyContainerListeners) {
        fireContainerEvent("removeEnvironment", name);
    }
}
Also used : ContextEnvironment(org.apache.catalina.deploy.ContextEnvironment)

Example 2 with ContextEnvironment

use of org.apache.catalina.deploy.ContextEnvironment 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 3 with ContextEnvironment

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

the class StandardContext method getEnvironments.

// -------------------- JMX methods  --------------------
/**
 * Return the MBean Names of the set of defined environment entries for
 * this web application
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = getNamingResources().findEnvironments();
    List<String> results = new ArrayList<String>();
    for (ContextEnvironment env : envs) {
        try {
            ObjectName oname = createObjectName(env);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for environment " + env);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);
}
Also used : ContextEnvironment(org.apache.catalina.deploy.ContextEnvironment) MalformedObjectNameException(javax.management.MalformedObjectNameException) ArrayList(java.util.ArrayList) ObjectName(javax.management.ObjectName)

Example 4 with ContextEnvironment

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

the class StandardContext method addEnvironment.

/**
 * Add an environment entry for this web application.
 *
 * @param environment New environment entry
 */
@Override
public void addEnvironment(ContextEnvironment environment) {
    ContextEnvironment env = findEnvironment(environment.getName());
    if ((env != null) && !env.getOverride())
        return;
    namingResources.addEnvironment(environment);
    if (notifyContainerListeners) {
        fireContainerEvent("addEnvironment", environment.getName());
    }
}
Also used : ContextEnvironment(org.apache.catalina.deploy.ContextEnvironment)

Example 5 with ContextEnvironment

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

the class WebModuleContextConfig method configureResource.

protected synchronized void configureResource() throws LifecycleException {
    List<ApplicationParameter> appParams = context.findApplicationParameters();
    ContextParameter contextParam;
    synchronized (appParams) {
        Iterator<ApplicationParameter> i = appParams.iterator();
        while (i.hasNext()) {
            ApplicationParameter appParam = i.next();
            contextParam = new EnvironmentProperty(appParam.getName(), appParam.getValue(), appParam.getDescription());
            webBundleDescriptor.addContextParameter(contextParam);
        }
    }
    ContextEnvironment[] envs = context.findEnvironments();
    EnvironmentProperty envEntry;
    for (int i = 0; i < envs.length; i++) {
        envEntry = new EnvironmentProperty(envs[i].getName(), envs[i].getValue(), envs[i].getDescription(), envs[i].getType());
        if (envs[i].getValue() != null) {
            envEntry.setValue(envs[i].getValue());
        }
        webBundleDescriptor.addEnvironmentProperty(envEntry);
        envProps.add(envEntry);
    }
    ContextResource[] resources = context.findResources();
    ResourceReferenceDescriptor resourceReference;
    Set<ResourceReferenceDescriptor> rrs = webBundleDescriptor.getResourceReferenceDescriptors();
    ResourcePrincipal rp;
    for (int i = 0; i < resources.length; i++) {
        resourceReference = new ResourceReferenceDescriptor(resources[i].getName(), resources[i].getDescription(), resources[i].getType());
        resourceReference.setJndiName(resources[i].getName());
        for (ResourceReferenceDescriptor rr : rrs) {
            if (resources[i].getName().equals(rr.getName())) {
                resourceReference.setJndiName(rr.getJndiName());
                rp = rr.getResourcePrincipal();
                if (rp != null) {
                    resourceReference.setResourcePrincipal(new ResourcePrincipal(rp.getName(), rp.getPassword()));
                }
            }
        }
        resourceReference.setAuthorization(resources[i].getAuth());
        webBundleDescriptor.addResourceReferenceDescriptor(resourceReference);
        resRefs.add(resourceReference);
    }
}
Also used : ContextEnvironment(org.apache.catalina.deploy.ContextEnvironment) ApplicationParameter(org.apache.catalina.deploy.ApplicationParameter) ContextParameter(com.sun.enterprise.deployment.web.ContextParameter) ContextResource(org.apache.catalina.deploy.ContextResource)

Aggregations

ContextEnvironment (org.apache.catalina.deploy.ContextEnvironment)5 ContextParameter (com.sun.enterprise.deployment.web.ContextParameter)1 ArrayList (java.util.ArrayList)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 ApplicationParameter (org.apache.catalina.deploy.ApplicationParameter)1 ContextResource (org.apache.catalina.deploy.ContextResource)1 NamingResources (org.apache.catalina.deploy.NamingResources)1