本文整理汇总了Java中javax.management.QueryEval.getMBeanServer方法的典型用法代码示例。如果您正苦于以下问题:Java QueryEval.getMBeanServer方法的具体用法?Java QueryEval.getMBeanServer怎么用?Java QueryEval.getMBeanServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.QueryEval
的用法示例。
在下文中一共展示了QueryEval.getMBeanServer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryMBeans
import javax.management.QueryEval; //导入方法依赖的package包/类
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;
}
示例2: filterListOfObjectInstances
import javax.management.QueryEval; //导入方法依赖的package包/类
/**
* Applies the specified queries to the set of ObjectInstances.
*/
private Set<ObjectInstance>
filterListOfObjectInstances(Set<ObjectInstance> list,
QueryExp query) {
// Null query.
//
if (query == null) {
return list;
} else {
Set<ObjectInstance> result = new HashSet<ObjectInstance>();
// Access the filter.
//
for (ObjectInstance oi : list) {
boolean res = false;
MBeanServer oldServer = QueryEval.getMBeanServer();
query.setMBeanServer(server);
try {
res = query.apply(oi.getObjectName());
} catch (Exception e) {
res = false;
} finally {
/*
* query.setMBeanServer is probably
* QueryEval.setMBeanServer so put back the old
* value. Since that method uses a ThreadLocal
* variable, this code is only needed for the
* unusual case where the user creates a custom
* QueryExp that calls a nested query on another
* MBeanServer.
*/
query.setMBeanServer(oldServer);
}
if (res) {
result.add(oi);
}
}
return result;
}
}
示例3: setQueryExpServer
import javax.management.QueryEval; //导入方法依赖的package包/类
/** Set the mbean server on the QueryExp and try and pass back any previously set one */
private static MBeanServer setQueryExpServer(QueryExp query, MBeanServer toSet) {
// We assume the QueryExp is a QueryEval subclass or uses the QueryEval thread local
// mechanism to store any existing MBeanServer. If that's not the case we have no
// way to access the old mbeanserver to let us restore it
MBeanServer result = QueryEval.getMBeanServer();
query.setMBeanServer(toSet);
return result;
}
示例4: apply
import javax.management.QueryEval; //导入方法依赖的package包/类
public boolean apply(final ObjectName name) {
final MBeanServer mbs = QueryEval.getMBeanServer();
return isInstanceOf(mbs, name, broadcasterClass);
}