Java Code Examples for com.sun.jmx.mbeanserver.MXBeanProxy#invoke()
The following examples show how to use
com.sun.jmx.mbeanserver.MXBeanProxy#invoke() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MBeanServerInvocationHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 2
Source File: MBeanServerInvocationHandler.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 3
Source File: MBeanServerInvocationHandler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 4
Source File: MBeanServerInvocationHandler.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 5
Source File: MBeanServerInvocationHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 6
Source File: MBeanServerInvocationHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 7
Source File: MBeanServerInvocationHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 8
Source File: MBeanServerInvocationHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 9
Source File: MBeanServerInvocationHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 10
Source File: MBeanServerInvocationHandler.java From Java8CN with Apache License 2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 11
Source File: MBeanServerInvocationHandler.java From hottub with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 12
Source File: MBeanServerInvocationHandler.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 13
Source File: MBeanServerInvocationHandler.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 14
Source File: MBeanServerInvocationHandler.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 15
Source File: MBeanServerInvocationHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }
Example 16
Source File: MBeanServerInvocationHandler.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final Class<?> methodClass = method.getDeclaringClass(); if (methodClass.equals(NotificationBroadcaster.class) || methodClass.equals(NotificationEmitter.class)) return invokeBroadcasterMethod(proxy, method, args); // local or not: equals, toString, hashCode if (shouldDoLocally(proxy, method)) return doLocally(proxy, method, args); try { if (isMXBean()) { MXBeanProxy p = findMXBeanProxy(methodClass); return p.invoke(connection, objectName, method, args); } else { final String methodName = method.getName(); final Class<?>[] paramTypes = method.getParameterTypes(); final Class<?> returnType = method.getReturnType(); /* Inexplicably, InvocationHandler specifies that args is null when the method takes no arguments rather than a zero-length array. */ final int nargs = (args == null) ? 0 : args.length; if (methodName.startsWith("get") && methodName.length() > 3 && nargs == 0 && !returnType.equals(Void.TYPE)) { return connection.getAttribute(objectName, methodName.substring(3)); } if (methodName.startsWith("is") && methodName.length() > 2 && nargs == 0 && (returnType.equals(Boolean.TYPE) || returnType.equals(Boolean.class))) { return connection.getAttribute(objectName, methodName.substring(2)); } if (methodName.startsWith("set") && methodName.length() > 3 && nargs == 1 && returnType.equals(Void.TYPE)) { Attribute attr = new Attribute(methodName.substring(3), args[0]); connection.setAttribute(objectName, attr); return null; } final String[] signature = new String[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) signature[i] = paramTypes[i].getName(); return connection.invoke(objectName, methodName, args, signature); } } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException re) { throw re.getTargetException(); } catch (RuntimeErrorException rre) { throw rre.getTargetError(); } /* The invoke may fail because it can't get to the MBean, with one of the these exceptions declared by MBeanServerConnection.invoke: - RemoteException: can't talk to MBeanServer; - InstanceNotFoundException: objectName is not registered; - ReflectionException: objectName is registered but does not have the method being invoked. In all of these cases, the exception will be wrapped by the proxy mechanism in an UndeclaredThrowableException unless it happens to be declared in the "throws" clause of the method being invoked on the proxy. */ }