javax.management.ObjectName.getKeyPropertyList()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中javax.management.ObjectName.getKeyPropertyList()方法的一些代码示例,展示了ObjectName.getKeyPropertyList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectName.getKeyPropertyList()方法的具体详情如下:
包路径:javax.management.ObjectName
类名称:ObjectName
方法名:getKeyPropertyList

ObjectName.getKeyPropertyList介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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)
 */
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);
}

代码示例来源:origin: apache/activemq

public static ObjectName createNetworkBridgeObjectName(ObjectName connectorName, String remoteAddress) throws MalformedObjectNameException {
  Hashtable<String, String> map = new Hashtable<String, String>(connectorName.getKeyPropertyList());
  map.put("networkBridge", JMXSupport.encodeObjectNamePart(remoteAddress));
  return new ObjectName(connectorName.getDomain(), map);
}

代码示例来源:origin: org.springframework/spring-context

/**
 * 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)
 */
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);
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * @param on ObjectName instance to work with.
 * @return A simple reference based on passed <code>on</code>
 */
public static Reference getReference(final ObjectName on) {
  Reference r = new Reference(String.class.getName());
  Hashtable<String,String> ht = on.getKeyPropertyList();
  r.add(new StringRefAddr("host", (String)ht.get("host")));
  r.add(new StringRefAddr("name", (String)ht.get("name")));
  // Put in a value to serve as a unique 'key'.
  r.add(new StringRefAddr("key",
      on.getCanonicalKeyPropertyListString()));
  return r;
}

代码示例来源:origin: neo4j/neo4j

private MBeanInfo kernelMBeanInfo() throws Exception
  {
    Kernel kernel = ((GraphDatabaseAPI) graphdb).getDependencyResolver().resolveDependency( JmxKernelExtension
        .class ).getSingleManagementBean( Kernel.class );
    ObjectName query = kernel.getMBeanQuery();
    Hashtable<String, String> properties = new Hashtable<>( query.getKeyPropertyList() );
    properties.put( "name", Kernel.NAME );
    return getPlatformMBeanServer().getMBeanInfo( new ObjectName( query.getDomain(), properties ) );
  }
}

代码示例来源:origin: Netflix/servo

/**
 * Creates a tag list from an object name.
 */
private TagList createTagList(ObjectName name) {
 Map<String, String> props = name.getKeyPropertyList();
 SmallTagMap.Builder tagsBuilder = SmallTagMap.builder();
 for (Map.Entry<String, String> e : props.entrySet()) {
  String key = PROP_KEY_PREFIX + "." + e.getKey();
  tagsBuilder.add(Tags.newTag(key, e.getValue()));
 }
 tagsBuilder.add(Tags.newTag(DOMAIN_KEY, name.getDomain()));
 tagsBuilder.add(CLASS_TAG);
 if (defaultTags != null) {
  defaultTags.forEach(tagsBuilder::add);
 }
 return new BasicTagList(tagsBuilder.result());
}

代码示例来源:origin: apache/hbase

@Test
public void testBuildObjectName() throws MalformedObjectNameException {
 String[] keys = {"type", "name"};
 String[] values = {"MemoryPool", "Par Eden Space"};
 Hashtable<String, String> properties = JSONMetricUtil.buldKeyValueTable(keys, values);
 ObjectName testObject = JSONMetricUtil.buildObjectName(JSONMetricUtil.JAVA_LANG_DOMAIN,
  properties);
 assertEquals(JSONMetricUtil.JAVA_LANG_DOMAIN, testObject.getDomain());
 assertEquals(testObject.getKeyPropertyList(), properties);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Creates the ObjectName for the ConnectionPoolMBean object to be registered
 * @param original the ObjectName for the DataSource
 * @return the ObjectName for the ConnectionPoolMBean
 * @throws MalformedObjectNameException
 */
public ObjectName createObjectName(ObjectName original) throws MalformedObjectNameException {
  String domain = ConnectionPool.POOL_JMX_DOMAIN;
  Hashtable<String,String> properties = original.getKeyPropertyList();
  String origDomain = original.getDomain();
  properties.put("type", "ConnectionPool");
  properties.put("class", this.getClass().getName());
  if (original.getKeyProperty("path")!=null || properties.get("context")!=null) {
    //this ensures that if the registration came from tomcat, we're not losing
    //the unique domain, but putting that into as an engine attribute
    properties.put("engine", origDomain);
  }
  ObjectName name = new ObjectName(domain,properties);
  return name;
}

代码示例来源:origin: crashub/crash

Set<ObjectName> completions = new HashSet<ObjectName>();
for (ObjectName name : server.queryNames(null, null)) {
 if (name.getDomain().equals(domain) && name.getKeyPropertyList().entrySet().containsAll(keyValues.entrySet())) {
  completions.add(name);
 Completion.Builder b = new Completion.Builder(keyValue[0]);
 for (ObjectName name : completions) {
  for (String key : name.getKeyPropertyList().keySet()) {
   if (!keyValues.containsKey(key) && key.startsWith(keyValue[0])) {
    b.add(key.substring(keyValue[0].length()) + "=", false);
  String value = completion.getKeyProperty(keyValue[0]);
  if (value != null && value.startsWith(keyValue[1])) {
   Hashtable<String, String> a = completion.getKeyPropertyList();
   a.remove(keyValue[0]);
   a.keySet().removeAll(keyValues.keySet());

代码示例来源:origin: org.ow2.sirocco.vmm/sirocco-vmm-agent-core

protected ManagedResource(final ObjectName objectName, final Map<String, String> attributes) {
  this.objectName = objectName;
  this.path = objectName.getKeyPropertyList().get("name");
  if (attributes != null) {
    this.attributes.putAll(attributes);
  }
}

代码示例来源:origin: mercyblitz/thinking-in-spring-boot-samples

public static void main(String[] args) throws MalformedObjectNameException {
    ObjectName objectName = new ObjectName("thinking.in.springboot:name=小马哥,type=User,id=1");
    System.out.printf("Object[%s] 域名(Domain)为 : %s\n", objectName, objectName.getDomain());
    System.out.printf("Object[%s] 键属性(Key Properties)列表为 : %s\n", objectName, objectName.getKeyPropertyList());
  }
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-1.7-ui

public static ObjectName replaceKey(ObjectName beanName, String key, String value) {
 Hashtable keyPropertyList = beanName.getKeyPropertyList();
 Hashtable propertyList = new Hashtable(keyPropertyList);
 propertyList.put(key, value);
 try {
  return new ObjectName(beanName.getDomain(), propertyList);
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.jmx

public static ObjectName findServiceName( MBeanServer server, String applicationName, String serviceId )
    throws MalformedObjectNameException
  {
    ObjectName objectName = new ObjectName( "Polygene:application=" + applicationName + ",*,service=" + serviceId );
    return server.queryNames( objectName, null ).stream()
           .filter( item -> item.getKeyPropertyList().size() == 5 )
           .findFirst().orElse( null );
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

/**
 * Print an ObjectName format of an mbean
 * 
 * @param mbean - mbean to print
 */
public void printMBean(ObjectName mbean) {
  printMBean(mbean.getKeyPropertyList());
}

代码示例来源:origin: org.apache.activemq/activemq-broker

public static ObjectName createNetworkBridgeObjectName(ObjectName connectorName, String remoteAddress) throws MalformedObjectNameException {
  Hashtable<String, String> map = new Hashtable<String, String>(connectorName.getKeyPropertyList());
  map.put("networkBridge", JMXSupport.encodeObjectNamePart(remoteAddress));
  return new ObjectName(connectorName.getDomain(), map);
}

代码示例来源:origin: org.neo4j/neo4j-management

private static ObjectName createObjectName( ObjectName query, String beanName, boolean isQuery )
{
  Hashtable<String,String> properties = new Hashtable<>( query.getKeyPropertyList() );
  return createObjectName( query.getDomain(), properties, beanName, isQuery );
}

代码示例来源:origin: org.apache.activemq/activemq-all

public static ObjectName createNetworkBridgeObjectName(ObjectName connectorName, String remoteAddress) throws MalformedObjectNameException {
  Hashtable<String, String> map = new Hashtable<String, String>(connectorName.getKeyPropertyList());
  map.put("networkBridge", JMXSupport.encodeObjectNamePart(remoteAddress));
  return new ObjectName(connectorName.getDomain(), map);
}

代码示例来源:origin: pierre/meteo

@SuppressWarnings("unchecked")
protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException {
  ObjectName connectorName = getObjectName();
  Map<String, String> map = new HashMap<String, String>(connectorName.getKeyPropertyList());
  return new ObjectName(connectorName.getDomain() + ":" + "BrokerName=" + JMXSupport.encodeObjectNamePart((String)map.get("BrokerName")) + "," + "Type=NetworkBridge,"
             + "NetworkConnectorName=" + JMXSupport.encodeObjectNamePart((String)map.get("NetworkConnectorName")) + "," + "Name="
             + JMXSupport.encodeObjectNamePart(JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress())));
}

代码示例来源:origin: OpenNMS/opennms

private void addStringAttributesToCollectionSet(JMXDataSource ds, AbstractJmxSample sample,
    Resource resource, ObjectName objectName) {
  final String groupName = fixGroupName(JmxUtils.getGroupName(stringMap, sample.getMbean()));
  final String domain = objectName.getDomain();
  final Hashtable<String, String> properties = objectName.getKeyPropertyList();
  properties.forEach(
      (key, value) -> collectionSetBuilder.withStringAttribute(resource, groupName, key, value));
  if (domain != null) {
    collectionSetBuilder.withStringAttribute(resource, groupName, "domain", objectName.getDomain());
  }
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testBuildObjectName() throws MalformedObjectNameException {
 String[] keys = {"type", "name"};
 String[] values = {"MemoryPool", "Par Eden Space"};
 Hashtable<String, String> properties = JSONMetricUtil.buldKeyValueTable(keys, values);
 ObjectName testObject = JSONMetricUtil.buildObjectName(JSONMetricUtil.JAVA_LANG_DOMAIN,
  properties);
 assertEquals(JSONMetricUtil.JAVA_LANG_DOMAIN, testObject.getDomain());
 assertEquals(testObject.getKeyPropertyList(), properties);
}

相关文章