use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.
the class NamingResourcesMBean method getResources.
/**
* Return the MBean Names of all the defined resource references for this
* application.
* @return an array of object names as strings
*/
public String[] getResources() {
ContextResource[] resources = ((NamingResourcesImpl) this.resource).findResources();
List<String> results = new ArrayList<>();
for (ContextResource contextResource : resources) {
try {
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), contextResource);
results.add(oname.toString());
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException(sm.getString("namingResourcesMBean.createObjectNameError.resource", contextResource), e);
}
}
return results.toArray(new String[0]);
}
use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.
the class NamingResourcesMBean method addResourceLink.
/**
* Add a resource link reference for this web application.
*
* @param resourceLinkName New resource link reference name
* @param type New resource link reference type
* @return the object name of the new resource link
* @throws MalformedObjectNameException if the object name was invalid
*/
public String addResourceLink(String resourceLinkName, String type) throws MalformedObjectNameException {
NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
if (nresources == null) {
return null;
}
ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName);
if (resourceLink != null) {
throw new IllegalArgumentException(sm.getString("namingResourcesMBean.addAlreadyExists.resourceLink", resourceLinkName));
}
resourceLink = new ContextResourceLink();
resourceLink.setName(resourceLinkName);
resourceLink.setType(type);
nresources.addResourceLink(resourceLink);
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("ContextResourceLink");
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
return oname.toString();
}
use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat by apache.
the class NamingResourcesMBean method getEnvironments.
// ------------------------------------------------------------- Attributes
/**
* Return the MBean Names of the set of defined environment entries for
* this web application
* @return an array of object names as strings
*/
public String[] getEnvironments() {
ContextEnvironment[] envs = ((NamingResourcesImpl) this.resource).findEnvironments();
List<String> results = new ArrayList<>();
for (ContextEnvironment env : envs) {
try {
ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env);
results.add(oname.toString());
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException(sm.getString("namingResourcesMBean.createObjectNameError.environment", env), e);
}
}
return results.toArray(new String[0]);
}
use of org.apache.catalina.deploy.NamingResourcesImpl in project tomcat 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
* @return the object name of the new resource
* @throws MalformedObjectNameException if the object name was invalid
*/
public String addResource(String resourceName, String type) throws MalformedObjectNameException {
NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
if (nresources == null) {
return null;
}
ContextResource resource = nresources.findResource(resourceName);
if (resource != null) {
throw new IllegalArgumentException(sm.getString("namingResourcesMBean.addAlreadyExists.resource", 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();
}
Aggregations