Example usage for org.springframework.jmx.support ObjectNameManager getInstance

List of usage examples for org.springframework.jmx.support ObjectNameManager getInstance

Introduction

In this page you can find the example usage for org.springframework.jmx.support ObjectNameManager getInstance.

Prototype

public static ObjectName getInstance(String domainName, Hashtable<String, String> properties)
        throws MalformedObjectNameException 

Source Link

Document

Retrieve an ObjectName instance with the specified domain name and the supplied key/name properties.

Usage

From source file:org.springframework.jmx.support.JmxUtils.java

/**
 * Append an additional key/value pair to an existing {@link ObjectName} with the key being
 * the static value {@code identity} and the value being the identity hash code of the
 * managed resource being exposed on the supplied {@link ObjectName}. This can be used to
 * provide a unique {@link ObjectName} for each distinct instance of a particular bean or
 * class. Useful when generating {@link ObjectName ObjectNames} at runtime for a set of
 * managed resources based on the template value supplied by a
 * {@link org.springframework.jmx.export.naming.ObjectNamingStrategy}.
 * @param objectName the original JMX ObjectName
 * @param managedResource the MBean instance
 * @return an ObjectName with the MBean identity added
 * @throws MalformedObjectNameException in case of an invalid object name specification
 * @see org.springframework.util.ObjectUtils#getIdentityHexString(Object)
 *///from w ww  .j a va  2 s. c  o  m
public static ObjectName appendIdentityToObjectName(ObjectName objectName, Object managedResource)
        throws MalformedObjectNameException {

    Hashtable<String, String> keyProperties = objectName.getKeyPropertyList();
    keyProperties.put(IDENTITY_OBJECT_NAME_KEY, ObjectUtils.getIdentityHexString(managedResource));
    return ObjectNameManager.getInstance(objectName.getDomain(), keyProperties);
}