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:catalina.mbeans.NamingResourcesMBean.java

/**
 * 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 
 *//*www  . j a v a 2  s . c  o  m*/
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());

}

From source file:catalina.mbeans.DefaultContextMBean.java

/**
 * Add an environment entry for this web application.
 *
 * @param envName New environment entry name
 *///from ww  w . jav  a2 s  .c o  m
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
    ManagedBean managed = registry.findManagedBean("ContextEnvironment");
    ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env);
    return (oname.toString());

}

From source file:catalina.mbeans.NamingResourcesMBean.java

/**
 * Add a resource reference for this web application.
 *
 * @param resourceName New resource reference name
 * @param type New resource reference type
 *//*from w  w w  .  j a va  2  s.c o m*/
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());
}

From source file:com.betfair.cougar.core.impl.jmx.HtmlAdaptorParser.java

private void runOperation(StringBuilder buf, String son, String operation, String separator) {
    try {/* w  w w  .  j  a va2s.com*/
        ObjectName on = new ObjectName(son);
        Object result = mbs.invoke(on, operation, new Object[0], new String[0]);
        buf.append(on.toString()).append(separator).append(operation).append(separator).append(result)
                .append(separator);
    } catch (Exception e) {
        LOGGER.debug("Unable to run operation {} on bean {} ", operation, separator);

    }
}

From source file:catalina.mbeans.StandardContextMBean.java

/**
 * Add a resource reference for this web application.
 *
 * @param resourceName New resource reference name
 *///  ww  w  . j  a  va 2 s .c  om
public String addResource(String resourceName, String type) throws MalformedObjectNameException {

    NamingResources nresources = getNamingResources();
    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());
}

From source file:catalina.mbeans.DefaultContextMBean.java

/**
 * Add a resource reference for this web application.
 *
 * @param resourceName New resource reference name
 *//*from  w w w  . jav a 2s  . co  m*/
public String addResource(String resourceName, String type) throws MalformedObjectNameException {

    NamingResources nresources = getNamingResources();
    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());
}

From source file:catalina.mbeans.NamingResourcesMBean.java

/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application//from   w  ww .  j  a v  a2 s . c o m
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = ((NamingResources) this.resource).findEnvironments();
    ArrayList results = new ArrayList();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), 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:catalina.mbeans.NamingResourcesMBean.java

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

    NamingResources nresources = (NamingResources) this.resource;
    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.setName(resourceLinkName);
    resourceLink.setType(type);
    resourceLink.setGlobal(global);
    nresources.addResourceLink(resourceLink);

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

From source file:catalina.mbeans.DefaultContextMBean.java

/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application/*w w  w .j  a  v a  2 s  .c  om*/
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = getNamingResources().findEnvironments();
    ArrayList results = new ArrayList();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), 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:catalina.mbeans.DefaultContextMBean.java

/**
 * Return the MBean Names of all the defined resource links for this 
 * application//  w w  w. j  av a2s .co  m
 */
public String[] getResourceLinks() {

    ContextResourceLink[] links = getNamingResources().findResourceLinks();
    ArrayList results = new ArrayList();
    for (int i = 0; i < links.length; i++) {
        try {
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), 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()]));

}