Example usage for org.springframework.jmx.access MBeanInfoRetrievalException MBeanInfoRetrievalException

List of usage examples for org.springframework.jmx.access MBeanInfoRetrievalException MBeanInfoRetrievalException

Introduction

In this page you can find the example usage for org.springframework.jmx.access MBeanInfoRetrievalException MBeanInfoRetrievalException.

Prototype

public MBeanInfoRetrievalException(String msg, Throwable cause) 

Source Link

Document

Create a new MBeanInfoRetrievalException with the specified error message and root cause.

Usage

From source file:org.springframework.jmx.access.MBeanClientInterceptor.java

/**
 * Loads the management interface info for the configured MBean into the caches.
 * This information is used by the proxy when determining whether an invocation matches
 * a valid operation or attribute on the management interface of the managed resource.
 *//*  w  w w.ja  v  a2  s  . c om*/
private void retrieveMBeanInfo(MBeanServerConnection server) throws MBeanInfoRetrievalException {
    try {
        MBeanInfo info = server.getMBeanInfo(this.objectName);

        MBeanAttributeInfo[] attributeInfo = info.getAttributes();
        this.allowedAttributes = new HashMap<>(attributeInfo.length);
        for (MBeanAttributeInfo infoEle : attributeInfo) {
            this.allowedAttributes.put(infoEle.getName(), infoEle);
        }

        MBeanOperationInfo[] operationInfo = info.getOperations();
        this.allowedOperations = new HashMap<>(operationInfo.length);
        for (MBeanOperationInfo infoEle : operationInfo) {
            Class<?>[] paramTypes = JmxUtils.parameterInfoToTypes(infoEle.getSignature(), this.beanClassLoader);
            this.allowedOperations.put(new MethodCacheKey(infoEle.getName(), paramTypes), infoEle);
        }
    } catch (ClassNotFoundException ex) {
        throw new MBeanInfoRetrievalException("Unable to locate class specified in method signature", ex);
    } catch (IntrospectionException ex) {
        throw new MBeanInfoRetrievalException("Unable to obtain MBean info for bean [" + this.objectName + "]",
                ex);
    } catch (InstanceNotFoundException ex) {
        // if we are this far this shouldn't happen, but...
        throw new MBeanInfoRetrievalException(
                "Unable to obtain MBean info for bean [" + this.objectName
                        + "]: it is likely that this bean was unregistered during the proxy creation process",
                ex);
    } catch (ReflectionException ex) {
        throw new MBeanInfoRetrievalException("Unable to read MBean info for bean [ " + this.objectName + "]",
                ex);
    } catch (IOException ex) {
        throw new MBeanInfoRetrievalException("An IOException occurred when communicating with the "
                + "MBeanServer. It is likely that you are communicating with a remote MBeanServer. "
                + "Check the inner exception for exact details.", ex);
    }
}