use of org.apache.catalina.deploy.ContextResource in project tomcat70 by apache.
the class NamingResourcesMBean method removeResource.
/**
* Remove any resource reference with the specified name.
*
* @param resourceName Name of the resource reference to remove
*/
public void removeResource(String resourceName) {
resourceName = ObjectName.unquote(resourceName);
NamingResources nresources = (NamingResources) this.resource;
if (nresources == null) {
return;
}
ContextResource resource = nresources.findResource(resourceName);
if (resource == null) {
throw new IllegalArgumentException("Invalid resource name '" + resourceName + "'");
}
nresources.removeResource(resourceName);
}
use of org.apache.catalina.deploy.ContextResource in project tomcat70 by apache.
the class NamingResourcesMBean method getResources.
/**
* Return the MBean Names of all the defined resource references for this
* application.
*/
public String[] getResources() {
ContextResource[] resources = ((NamingResources) this.resource).findResources();
ArrayList<String> results = new ArrayList<String>();
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 results.toArray(new String[results.size()]);
}
use of org.apache.catalina.deploy.ContextResource in project Payara by payara.
the class StandardContext method removeResource.
/**
* Remove any resource reference with the specified name.
*
* @param resourceName Name of the resource reference to remove
*/
@Override
public void removeResource(String resourceName) {
String decoded = URLDecoder.decode(resourceName);
if (namingResources == null) {
return;
}
ContextResource resource = namingResources.findResource(decoded);
if (resource == null) {
throw new IllegalArgumentException("Invalid resource name '" + decoded + "'");
}
namingResources.removeResource(decoded);
if (notifyContainerListeners) {
fireContainerEvent("removeResource", decoded);
}
}
use of org.apache.catalina.deploy.ContextResource 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