本文整理汇总了Java中javax.management.ObjectName.WILDCARD属性的典型用法代码示例。如果您正苦于以下问题:Java ObjectName.WILDCARD属性的具体用法?Java ObjectName.WILDCARD怎么用?Java ObjectName.WILDCARD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.management.ObjectName
的用法示例。
在下文中一共展示了ObjectName.WILDCARD属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
public static void main(String[] args) throws Exception {
System.out.println(
"Test that <MBeanServerDelegate.DELEGATE_NAME> equals " +
"<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>");
final ObjectName delegateName =
new ObjectName("JMImplementation:type=MBeanServerDelegate");
if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME))
throw new AssertionError("Unexpected value: " +
"MBeanServerDelegate.DELEGATE_NAME = " +
MBeanServerDelegate.DELEGATE_NAME);
System.out.println("MBeanServerDelegate.DELEGATE_NAME = " +
"new ObjectName(\"" + delegateName + "\")");
System.out.println("Test that <ObjectName.WILDCARD> " +
"equals <new ObjectName(\"*:*\")>");
final ObjectName wildcardName = new ObjectName("*:*");
if (!wildcardName.equals(ObjectName.WILDCARD))
throw new AssertionError("Unexpected value: " +
"ObjectName.WILDCARD = " +
ObjectName.WILDCARD);
System.out.println("ObjectName.WILDCARD = " +
"new ObjectName(\"" + wildcardName + "\")");
System.out.println("Test passes: constants were initialized properly");
}
示例2: queryMBeans
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
Set<ObjectInstance> instances = newSet();
if (name == null)
name = ObjectName.WILDCARD;
if (query == null)
query = trueQuery;
MBeanServer oldMBS = QueryEval.getMBeanServer();
try {
query.setMBeanServer(this);
for (ObjectName n : mbeans.keySet()) {
if (name.apply(n)) {
try {
if (query.apply(n))
instances.add(getObjectInstance(n));
} catch (Exception e) {
// OK: Ignore this MBean in the result
}
}
}
} finally {
query.setMBeanServer(oldMBS);
}
return instances;
}