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

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

Introduction

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

Prototype

public MBeanConnectFailureException(String msg, Throwable cause) 

Source Link

Document

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

Usage

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

/**
 * Route the invocation to the configured managed resource. Correctly routes JavaBean property
 * access to {@code MBeanServerConnection.get/setAttribute} and method invocation to
 * {@code MBeanServerConnection.invoke}.
 * @param invocation the {@code MethodInvocation} to re-route
 * @return the value returned as a result of the re-routed invocation
 * @throws Throwable an invocation error propagated to the user
 *//*w w w  . j  a  v  a  2 s  . co m*/
@Nullable
protected Object doInvoke(MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();
    try {
        Object result;
        if (this.invocationHandler != null) {
            result = this.invocationHandler.invoke(invocation.getThis(), method, invocation.getArguments());
        } else {
            PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
            if (pd != null) {
                result = invokeAttribute(pd, invocation);
            } else {
                result = invokeOperation(method, invocation.getArguments());
            }
        }
        return convertResultValueIfNecessary(result, new MethodParameter(method, -1));
    } catch (MBeanException ex) {
        throw ex.getTargetException();
    } catch (RuntimeMBeanException ex) {
        throw ex.getTargetException();
    } catch (RuntimeErrorException ex) {
        throw ex.getTargetError();
    } catch (RuntimeOperationsException ex) {
        // This one is only thrown by the JMX 1.2 RI, not by the JDK 1.5 JMX code.
        RuntimeException rex = ex.getTargetException();
        if (rex instanceof RuntimeMBeanException) {
            throw ((RuntimeMBeanException) rex).getTargetException();
        } else if (rex instanceof RuntimeErrorException) {
            throw ((RuntimeErrorException) rex).getTargetError();
        } else {
            throw rex;
        }
    } catch (OperationsException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new InvalidInvocationException(ex.getMessage());
        }
    } catch (JMException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new InvocationFailureException("JMX access failed", ex);
        }
    } catch (IOException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new MBeanConnectFailureException("I/O failure during JMX access", ex);
        }
    }
}