本文整理匯總了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;
}