Example usage for javax.management MBeanInfo getClassName

List of usage examples for javax.management MBeanInfo getClassName

Introduction

In this page you can find the example usage for javax.management MBeanInfo getClassName.

Prototype

public String getClassName() 

Source Link

Document

Returns the name of the Java class of the MBean described by this MBeanInfo .

Usage

From source file:org.hyperic.hq.product.jmx.MxServerQuery.java

private void findServices(MBeanServerConnection mServer, MxServiceQuery query) throws PluginException {

    boolean isDebug = log.isDebugEnabled();

    query.initialize();//from   w  w w .j a v a  2 s.  c o  m

    Set services;
    ObjectName name;
    String mbeanClass = query.getMBeanClass();

    String filter = query.getObjectNameFilter();
    StringMatcher matcher = null;
    if (filter != null) {
        matcher = new StringMatcher();
        if (filter.charAt(0) == '!') {
            matcher.setExcludes(filter.substring(1));
        } else {
            matcher.setIncludes(filter);
        }
    }

    try {
        name = new ObjectName(query.getQueryName());
        log.debug("[findServices] name=" + name);
        services = mServer.queryNames(name, null);
        log.debug("[findServices] services=(" + services.size() + ")" + services);
    } catch (MalformedObjectNameException e) {
        String msg = query.getQueryName() + ": " + e.getMessage();
        throw new IllegalArgumentException(msg);
    } catch (RemoteException e) {
        throw new PluginException("Cannot connect to server", e);
    } catch (IOException e) {
        throw new PluginException("Cannot connect to server", e);
    }

    for (Iterator it = services.iterator(); it.hasNext();) {
        name = (ObjectName) it.next();

        if ((matcher != null) && !matcher.matches(name.toString())) {
            if (isDebug) {
                log.debug("[" + name + "] !matches(" + matcher + ")");
            }
            continue;
        }

        if (!query.apply(name)) {
            continue;
        }

        if (mbeanClass != null) {
            try {
                MBeanInfo info = mServer.getMBeanInfo(name);
                if (!info.getClassName().matches(mbeanClass)) {
                    if (isDebug) {
                        log.debug("[" + name + "] " + info.getClassName() + " !instanceof " + mbeanClass);
                    }
                    continue;
                }
            } catch (Exception e) {
                log.error("mServer.getMBeanInfo(" + name + "): " + e);
                continue;
            }
        }

        MxServiceQuery service = query.cloneInstance();
        service.setObjectName(name);

        this.services.add(service);
        service.setParent(this);
        service.setServerQuery(this);
        service.getAttributes(mServer);
    }
}

From source file:org.jboss.test.cluster.apache_tomcat.HttpSessionReplicationTestCase.java

/**
 * Starts the Tomcat MBean running on a particular node
 *
 * @param instancenum Instance Number of the node
 * @throws Exception/*from www. j a v  a  2s  .c  o m*/
 */
private void startTomcatInstance(int instancenum) throws Exception {
    String jndi = getJNDIUrl(instancenum);
    getLog().debug("JNDI URL Obtained=  " + jndi);
    JBossRMIAdaptorHelper server = new JBossRMIAdaptorHelper(jndi);
    //Get the MBeanInfo for the Tomcat MBean
    ObjectName name = new ObjectName("jboss.web:service=WebServer");
    MBeanInfo info = server.getMBeanInfo(name);
    System.out.println("Tomcat MBean:" + info.getClassName());

    getLog().debug("Going to start tomcat  ");
    //Going to stop the Tomcat Instance
    server.invokeOperation(name, "start", null, null);
    this.sleepThread(10);
    server.invokeOperation(name, "startConnectors", null, null);
}

From source file:org.jboss.test.cluster.apache_tomcat.HttpSessionReplicationTestCase.java

/**
 * Shuts down the Tomcat MBean running on a particular node
 *
 * @param instancenum Instance Number of the node
 * @throws Exception/*from   w  ww  .jav a 2s. c om*/
 */
private void shutDownTomcatInstance(int instancenum) throws Exception {
    String jndi = getJNDIUrl(instancenum);
    getLog().debug("JNDI URL Obtained=  " + jndi);
    JBossRMIAdaptorHelper server = new JBossRMIAdaptorHelper(jndi);
    //Get the MBeanInfo for the Tomcat MBean
    ObjectName name = new ObjectName("jboss.web:service=WebServer");
    MBeanInfo info = server.getMBeanInfo(name);
    System.out.println("Tomcat MBean:" + info.getClassName());

    getLog().debug("Going to stop tomcat  ");
    //Going to stop the Tomcat Instance
    server.invokeOperation(name, "stop", null, null);
}