Example usage for javax.management MBeanServer getDefaultDomain

List of usage examples for javax.management MBeanServer getDefaultDomain

Introduction

In this page you can find the example usage for javax.management MBeanServer getDefaultDomain.

Prototype

public String getDefaultDomain();

Source Link

Usage

From source file:org.eclipse.ecr.core.storage.sql.reload.RepositoryReloader.java

public static MBeanServer locateJBoss() {
    for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) {
        if (server.getDefaultDomain().equals("jboss")) {
            return server;
        }//from w w  w.j  a  va 2 s. co  m
    }
    return null;
}

From source file:org.jboss.web.tomcat.service.session.JBossCacheCluster.java

/**
 * Registers this object and the tree cache (if we created it) with JMX.
 *//*from   w w  w. j  ava2 s .  c om*/
private void registerMBeans() {
    try {
        MBeanServer server = getMBeanServer();

        String domain;
        if (container instanceof ContainerBase) {
            domain = ((ContainerBase) container).getDomain();
        } else {
            domain = server.getDefaultDomain();
        }

        String name = ":type=Cluster";
        if (container instanceof Host) {
            name += ",host=" + container.getName();
        } else if (container instanceof Engine) {
            name += ",engine=" + container.getName();
        }

        ObjectName clusterName = new ObjectName(domain + name);

        if (server.isRegistered(clusterName)) {
            log.warn("MBean " + clusterName + " already registered");
        } else {
            this.objectName = clusterName;
            server.registerMBean(this, objectName);
        }

    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
    }
}

From source file:org.jboss.web.tomcat.tc5.session.JBossCacheCluster.java

/**
 * Registers this object and the tree cache (if we created it) with JMX.
 *///from   w w  w  .jav  a2 s  .c  o  m
private void registerMBeans() {
    try {
        MBeanServer server = getMBeanServer();

        String domain;
        if (container instanceof ContainerBase) {
            domain = ((ContainerBase) container).getDomain();
        } else {
            domain = server.getDefaultDomain();
        }

        String name = ":type=Cluster";
        if (container instanceof Host) {
            name += ",host=" + container.getName();
        } else if (container instanceof Engine) {
            name += ",engine=" + container.getName();
        }

        ObjectName clusterName = new ObjectName(domain + name);

        if (server.isRegistered(clusterName)) {
            log.warn("MBean " + clusterName + " already registered");
        } else {
            this.objectName = clusterName;
            server.registerMBean(this, objectName);
        }

        if (treeCacheLocal) {
            // Register the treeCache
            ObjectName treeCacheName = new ObjectName(treeCacheObjectName);
            server.registerMBean(getTreeCache(), treeCacheName);
        }

    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
    }
}

From source file:org.nuxeo.runtime.management.ServerLocatorService.java

@SuppressWarnings("cast")
protected MBeanServer doFindServer(String domainName) {
    for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) {
        String domain = server.getDefaultDomain();
        if (domain == null || !domain.equals(domainName)) {
            continue;
        }//www . ja v  a2  s .c o m
        return server;
    }
    return defaultServer;
}

From source file:org.rhq.plugins.jbossas.util.JBossMBeanUtility.java

public static MBeanServer getJBossMBeanServer() {
    List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
    MBeanServer jbossServer = null;
    for (MBeanServer server : servers) {
        if ("jboss".equals(server.getDefaultDomain())) {
            jbossServer = server;//from   w w w  .j a  v a 2s. co  m
        }
    }
    if (jbossServer == null) {
        jbossServer = ManagementFactory.getPlatformMBeanServer();
    }
    return jbossServer;
}