Search in sources :

Example 1 with ApplicationParameter

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

the class StandardContext method removeApplicationParameter.

/**
 * Remove the application parameter with the specified name from
 * the set for this application.
 *
 * @param name Name of the application parameter to remove
 */
@Override
public void removeApplicationParameter(String name) {
    ApplicationParameter match = null;
    Iterator<ApplicationParameter> i = applicationParameters.iterator();
    while (i.hasNext()) {
        ApplicationParameter applicationParameter = i.next();
        // Make sure this parameter is currently present
        if (name.equals(applicationParameter.getName())) {
            match = applicationParameter;
            break;
        }
    }
    if (match != null) {
        applicationParameters.remove(match);
        // Inform interested listeners
        if (notifyContainerListeners) {
            fireContainerEvent("removeApplicationParameter", name);
        }
    }
}
Also used : ApplicationParameter(org.apache.catalina.deploy.ApplicationParameter)

Example 2 with ApplicationParameter

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

the class StandardContext method addApplicationParameter.

/**
 * Add a new application parameter for this application.
 *
 * @param parameter The new application parameter
 */
@Override
public void addApplicationParameter(ApplicationParameter parameter) {
    String newName = parameter.getName();
    Iterator<ApplicationParameter> i = applicationParameters.iterator();
    while (i.hasNext()) {
        ApplicationParameter applicationParameter = i.next();
        if (newName.equals(applicationParameter.getName())) {
            if (applicationParameter.getOverride()) {
                applicationParameter.setValue(parameter.getValue());
            }
            return;
        }
    }
    applicationParameters.add(parameter);
    if (notifyContainerListeners) {
        fireContainerEvent("addApplicationParameter", parameter);
    }
}
Also used : ApplicationParameter(org.apache.catalina.deploy.ApplicationParameter)

Example 3 with ApplicationParameter

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

the class StandardContext method mergeParameters.

/**
 * Merge the context initialization parameters specified in the application
 * deployment descriptor with the application parameters described in the
 * server configuration, respecting the <code>override</code> property of
 * the application parameters appropriately.
 */
private void mergeParameters() {
    Map<String, String> mergedParams = new HashMap<>();
    for (String name : findParameters()) {
        mergedParams.put(name, findParameter(name));
    }
    for (ApplicationParameter param : findApplicationParameters()) {
        if (param.getOverride()) {
            if (mergedParams.get(param.getName()) == null)
                mergedParams.put(param.getName(), param.getValue());
        } else {
            mergedParams.put(param.getName(), param.getValue());
        }
    }
    ServletContext sc = getServletContext();
    for (Map.Entry<String, String> entry : mergedParams.entrySet()) {
        sc.setInitParameter(entry.getKey(), entry.getValue());
    }
}
Also used : ApplicationParameter(org.apache.catalina.deploy.ApplicationParameter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ServletContext(javax.servlet.ServletContext) FilterMap(org.apache.catalina.deploy.FilterMap) ServletMap(org.apache.catalina.deploy.ServletMap) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 4 with ApplicationParameter

use of org.apache.catalina.deploy.ApplicationParameter 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

ApplicationParameter (org.apache.catalina.deploy.ApplicationParameter)4 ContextParameter (com.sun.enterprise.deployment.web.ContextParameter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ServletContext (javax.servlet.ServletContext)1 ContextEnvironment (org.apache.catalina.deploy.ContextEnvironment)1 ContextResource (org.apache.catalina.deploy.ContextResource)1 FilterMap (org.apache.catalina.deploy.FilterMap)1 ServletMap (org.apache.catalina.deploy.ServletMap)1