Example usage for javax.management ObjectName toString

List of usage examples for javax.management ObjectName toString

Introduction

In this page you can find the example usage for javax.management ObjectName toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of the object name.

Usage

From source file:org.apache.catalina.core.StandardContext.java

/**
 * Return the MBean Names of the set of defined environment entries for
 * this web application//from   w w  w  .j  a  v a  2s .c  o  m
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = getNamingResources().findEnvironments();
    ArrayList results = new ArrayList();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(this.getEngineName(), envs[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Cannot create object name for environment " + envs[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}

From source file:org.apache.catalina.core.StandardContext.java

/**
 * Add a resource link for this web application.
 *
 * @param resourceLinkName New resource link name
 *//*from   w  w  w.java  2s  .c  om*/
public String addResourceLink(String resourceLinkName, String global, String name, String type)
        throws MalformedObjectNameException {

    NamingResources nresources = getNamingResources();
    if (nresources == null) {
        return null;
    }
    ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName);
    if (resourceLink != null) {
        throw new IllegalArgumentException(
                "Invalid resource link name - already exists'" + resourceLinkName + "'");
    }
    resourceLink = new ContextResourceLink();
    resourceLink.setGlobal(global);
    resourceLink.setName(resourceLinkName);
    resourceLink.setType(type);
    nresources.addResourceLink(resourceLink);

    // Return the corresponding MBean name
    ManagedBean managed = Registry.getRegistry().findManagedBean("ContextResourceLink");
    ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
    return (oname.toString());
}

From source file:org.apache.catalina.core.StandardContext.java

/**
 * Return the MBean Names of all the defined resource links for this
 * application//from  ww  w.  j  av  a  2s  . c  om
 */
public String[] getResourceLinks() {

    ContextResourceLink[] links = getNamingResources().findResourceLinks();
    ArrayList results = new ArrayList();
    for (int i = 0; i < links.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(this.getEngineName(), links[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Cannot create object name for resource " + links[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}

From source file:org.apache.catalina.core.StandardContext.java

/**
 * Return the MBean Names of all the defined resource references for this
 * application.//from w w w  .  ja  v a2 s .c  om
 */
public String[] getResourceNames() {

    ContextResource[] resources = getNamingResources().findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(this.getEngineName(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Cannot create object name for resource " + resources[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}