use of org.apache.catalina.deploy.NamingResources in project tomcat70 by apache.
the class NamingResourcesMBean method removeResourceLink.
/**
* Remove any resource link reference with the specified name.
*
* @param resourceLinkName Name of the resource link reference to remove
*/
public void removeResourceLink(String resourceLinkName) {
resourceLinkName = ObjectName.unquote(resourceLinkName);
NamingResources nresources = (NamingResources) this.resource;
if (nresources == null) {
return;
}
ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName);
if (resourceLink == null) {
throw new IllegalArgumentException("Invalid resource Link name '" + resourceLinkName + "'");
}
nresources.removeResourceLink(resourceLinkName);
}
use of org.apache.catalina.deploy.NamingResources in project tomcat70 by apache.
the class NamingResourcesMBean method removeEnvironment.
/**
* Remove any environment entry with the specified name.
*
* @param envName Name of the environment entry to remove
*/
public void removeEnvironment(String envName) {
NamingResources nresources = (NamingResources) this.resource;
if (nresources == null) {
return;
}
ContextEnvironment env = nresources.findEnvironment(envName);
if (env == null) {
throw new IllegalArgumentException("Invalid environment name '" + envName + "'");
}
nresources.removeEnvironment(envName);
}
use of org.apache.catalina.deploy.NamingResources in project tomcat70 by apache.
the class NamingResourcesMBean method addResource.
/**
* Add a resource reference for this web application.
*
* @param resourceName New resource reference name
* @param type New resource reference type
*/
public String addResource(String resourceName, String type) throws MalformedObjectNameException {
NamingResources nresources = (NamingResources) this.resource;
if (nresources == null) {
return null;
}
ContextResource resource = nresources.findResource(resourceName);
if (resource != null) {
throw new IllegalArgumentException("Invalid resource name - already exists'" + resourceName + "'");
}
resource = new ContextResource();
resource.setName(resourceName);
resource.setType(type);
nresources.addResource(resource);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("ContextResource");
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resource);
return (oname.toString());
}
use of org.apache.catalina.deploy.NamingResources in project tomcat70 by apache.
the class NamingResourcesMBean method getResourceLinks.
/**
* Return the MBean Names of all the defined resource link references for
* this application.
*/
public String[] getResourceLinks() {
ContextResourceLink[] resourceLinks = ((NamingResources) this.resource).findResourceLinks();
ArrayList<String> results = new ArrayList<String>();
for (int i = 0; i < resourceLinks.length; i++) {
try {
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
results.add(oname.toString());
} catch (MalformedObjectNameException e) {
IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for resource " + resourceLinks[i]);
iae.initCause(e);
throw iae;
}
}
return results.toArray(new String[results.size()]);
}
use of org.apache.catalina.deploy.NamingResources in project tomcat70 by apache.
the class NamingResourcesMBean method addEnvironment.
// ------------------------------------------------------------- Operations
/**
* Add an environment entry for this web application.
*
* @param envName New environment entry name
* @param type The type of the new environment entry
* @param value The value of the new environment entry
*/
public String addEnvironment(String envName, String type, String value) throws MalformedObjectNameException {
NamingResources nresources = (NamingResources) this.resource;
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);
env.setValue(value);
nresources.addEnvironment(env);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("ContextEnvironment");
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env);
return (oname.toString());
}
Aggregations