本文整理汇总了Java中javax.management.QueryEval类的典型用法代码示例。如果您正苦于以下问题:Java QueryEval类的具体用法?Java QueryEval怎么用?Java QueryEval使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryEval类属于javax.management包,在下文中一共展示了QueryEval类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例5: setUp
import javax.management.QueryEval; //导入依赖的package包/类
/**
* Create MBean server, register MBeans.
*/
public final void setUp() throws Exception {
// Get the Platform MBean Server
mbs = MBeanServerFactory.createMBeanServer();
// Sets the MBean server on which the query is to be performed.
new QueryEval() {
private static final long serialVersionUID = 3832902139541599280L;
}.setMBeanServer(mbs);
instances = new Hello[10];
names = new ObjectName[instances.length];
instances[0] = new Hello();
instances[1] = new Hello();
instances[2] = new Hello();
instances[1].setNumber(new Integer(123));
instances[1].setNumber1(new BigDecimal((double) 123123123));
instances[2].setIntNumber1(10);
instances[2].setIntNumber2(100);
instances[2].setLongNumber1(10);
instances[2].setLongNumber2(100);
instances[2].setDoubleNumber1(10);
instances[2].setDoubleNumber2(100);
instances[2].setFloatNumber1(10);
instances[2].setFloatNumber2(100);
instances[2].setBoolean1(true);
instances[2].setBoolean2(false);
instances[2].setNumber1(new BigDecimal((double) 10));
instances[2].setNumber2(new BigDecimal((double) 100));
// Register the Hello MBean
for (int i = 0; i < instances.length; i++) {
if (instances[i] != null) {
names[i] = new ObjectName(
"org.apache.harmony.test.func.api.javax.management:type=Hello"
+ i);
mbs.registerMBean(instances[i], names[i]);
}
}
}