Search in sources :

Example 1 with NamedObject

use of com.sun.jmx.mbeanserver.NamedObject in project jdk8u_jdk by JetBrains.

the class DefaultMBeanServerInterceptor method objectInstancesFromFilteredNamedObjects.

/**
     * Applies the specified queries to the set of NamedObjects.
     */
private Set<ObjectInstance> objectInstancesFromFilteredNamedObjects(Set<NamedObject> list, QueryExp query) {
    Set<ObjectInstance> result = new HashSet<ObjectInstance>();
    // No query ...
    if (query == null) {
        for (NamedObject no : list) {
            final DynamicMBean obj = no.getObject();
            final String className = safeGetClassName(obj);
            result.add(new ObjectInstance(no.getName(), className));
        }
    } else {
        // Access the filter
        MBeanServer oldServer = QueryEval.getMBeanServer();
        query.setMBeanServer(server);
        try {
            for (NamedObject no : list) {
                final DynamicMBean obj = no.getObject();
                boolean res;
                try {
                    res = query.apply(no.getName());
                } catch (Exception e) {
                    res = false;
                }
                if (res) {
                    String className = safeGetClassName(obj);
                    result.add(new ObjectInstance(no.getName(), className));
                }
            }
        } 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);
        }
    }
    return result;
}
Also used : DynamicMBean(javax.management.DynamicMBean) ObjectInstance(javax.management.ObjectInstance) NamedObject(com.sun.jmx.mbeanserver.NamedObject) IntrospectionException(javax.management.IntrospectionException) OperationsException(javax.management.OperationsException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ReflectionException(javax.management.ReflectionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RuntimeMBeanException(javax.management.RuntimeMBeanException) RuntimeErrorException(javax.management.RuntimeErrorException) ListenerNotFoundException(javax.management.ListenerNotFoundException) RuntimeOperationsException(javax.management.RuntimeOperationsException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) JMRuntimeException(javax.management.JMRuntimeException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) HashSet(java.util.HashSet) MBeanServer(javax.management.MBeanServer)

Example 2 with NamedObject

use of com.sun.jmx.mbeanserver.NamedObject in project jdk8u_jdk by JetBrains.

the class DefaultMBeanServerInterceptor method objectNamesFromFilteredNamedObjects.

/**
     * Applies the specified queries to the set of NamedObjects.
     */
private Set<ObjectName> objectNamesFromFilteredNamedObjects(Set<NamedObject> list, QueryExp query) {
    Set<ObjectName> result = new HashSet<ObjectName>();
    // No query ...
    if (query == null) {
        for (NamedObject no : list) {
            result.add(no.getName());
        }
    } else {
        // Access the filter
        final MBeanServer oldServer = QueryEval.getMBeanServer();
        query.setMBeanServer(server);
        try {
            for (NamedObject no : list) {
                boolean res;
                try {
                    res = query.apply(no.getName());
                } catch (Exception e) {
                    res = false;
                }
                if (res) {
                    result.add(no.getName());
                }
            }
        } 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);
        }
    }
    return result;
}
Also used : NamedObject(com.sun.jmx.mbeanserver.NamedObject) IntrospectionException(javax.management.IntrospectionException) OperationsException(javax.management.OperationsException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ReflectionException(javax.management.ReflectionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RuntimeMBeanException(javax.management.RuntimeMBeanException) RuntimeErrorException(javax.management.RuntimeErrorException) ListenerNotFoundException(javax.management.ListenerNotFoundException) RuntimeOperationsException(javax.management.RuntimeOperationsException) AttributeNotFoundException(javax.management.AttributeNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) JMRuntimeException(javax.management.JMRuntimeException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) HashSet(java.util.HashSet) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Aggregations

NamedObject (com.sun.jmx.mbeanserver.NamedObject)2 HashSet (java.util.HashSet)2 AttributeNotFoundException (javax.management.AttributeNotFoundException)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 IntrospectionException (javax.management.IntrospectionException)2 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)2 JMRuntimeException (javax.management.JMRuntimeException)2 ListenerNotFoundException (javax.management.ListenerNotFoundException)2 MBeanException (javax.management.MBeanException)2 MBeanRegistrationException (javax.management.MBeanRegistrationException)2 MBeanServer (javax.management.MBeanServer)2 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)2 OperationsException (javax.management.OperationsException)2 ReflectionException (javax.management.ReflectionException)2 RuntimeErrorException (javax.management.RuntimeErrorException)2 RuntimeMBeanException (javax.management.RuntimeMBeanException)2 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 DynamicMBean (javax.management.DynamicMBean)1 ObjectInstance (javax.management.ObjectInstance)1