Example usage for javax.management ObjectName ObjectName

List of usage examples for javax.management ObjectName ObjectName

Introduction

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

Prototype

public ObjectName(String domain, Hashtable<String, String> table) throws MalformedObjectNameException 

Source Link

Document

Construct an object name with several key properties from a Hashtable.

Usage

From source file:com.linkedin.databus2.relay.GoldenGateEventProducer.java

private void registerMbeans(GGMonitoredSourceInfo source) throws DatabusException {
    try {/*w  w  w  .j  ava 2 s  .  c om*/
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put("type", "SourceStatistics");
        props.put("name", source.getSourceName());
        ObjectName objectName = new ObjectName(ServerContainer.JMX_DOMAIN, props);

        if (_mbeanServer.isRegistered(objectName)) {
            _log.warn("Unregistering old gg-source statistics mbean: " + objectName);
            _mbeanServer.unregisterMBean(objectName);
        }

        _mbeanServer.registerMBean(source.getStatisticsBean(), objectName);
        _log.info("Registered gg-source statistics mbean: " + objectName);
        _registeredMbeans.add(objectName);
    } catch (Exception ex) {
        _log.error("Failed to register the gg-source statistics mbean for source (" + source.getSourceName()
                + ") due to an exception.", ex);
        throw new DatabusException("Failed to initialize gg event statistics mbeans.", ex);
    }

}

From source file:it.greenvulcano.jmx.impl.KarafJMXEntryPoint.java

private ObjectName calculateObjectName(Object object, MBeanServer mserver, ManagedBean managed,
        Map<String, String> properties, String descriptorName) throws Exception {
    String domain = managed.getDomain();
    if (domain == null) {
        domain = mserver.getDefaultDomain();
    }//  www .  java2  s. c  o  m

    String name = managed.getName();
    String className = managed.getClassName();
    String group = managed.getGroup();
    String type = managed.getType();

    Hashtable<String, String> keyProperties = new Hashtable<String, String>();
    keyProperties.put("Name", name);
    keyProperties.put("Class", className);
    keyProperties.put("Group", group);
    keyProperties.put("Type", type);
    if (properties != null) {
        keyProperties.putAll(properties);
    }

    if (objectNameBuilders != null) {
        for (int i = 0; i < objectNameBuilders.size(); i++) {
            ObjectNameBuilder onb = objectNameBuilders.get(i);
            keyProperties = onb.resolve(descriptorName, keyProperties, object);
        }
    }

    ObjectName oname = new ObjectName(domain, keyProperties);

    return oname;
}

From source file:it.greenvulcano.jmx.impl.KarafJMXEntryPoint.java

private ObjectName calculateMBeanName(Object mbean, MBeanServer mserver, Map<String, String> properties,
        String descriptorName) throws Exception {
    String domain = mserver.getDefaultDomain();

    Hashtable<String, String> keyProperties = new Hashtable<String, String>();
    if (properties != null) {
        keyProperties.putAll(properties);
    }/* w w  w.  j av  a2 s .com*/

    if (objectNameBuilders != null) {
        for (int i = 0; i < objectNameBuilders.size(); i++) {
            ObjectNameBuilder onb = objectNameBuilders.get(i);
            keyProperties = onb.resolve(descriptorName, keyProperties, mbean);
        }
    }

    ObjectName oname = new ObjectName(domain, keyProperties);

    return oname;
}