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);
}
}
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();
}
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()]);
}
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());
}
}
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);
}
}
Aggregations