/** * Return a proxy implementing all the interfaces specified that forward * method invocations to the specified MBean. * * @param <T> * @param mbeanInterface the interface the proxy should implement (the MBean * should obviously also implement that interface). * @param jmxServiceUrl the JMX service URL * @param jmxObjectName the name the MBean has been registered to * @return a proxy implementing the specified interface and that forward * method invocations to the specified MBean. * * @throws IOException for any IO problem * @throws MalformedObjectNameException for any JMX Naming problem * @throws MBeanException for any MBean problem * @throws ReflectionException for any problem related to reflection */ @SuppressWarnings("unchecked") public static <T> T getMBeanProxy(final Class<T> mbeanInterface, final String jmxServiceUrl, final String jmxObjectName) throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException, ReflectionException { return (T) Proxy.newProxyInstance(Misc.class.getClassLoader(), new Class[] { mbeanInterface }, new MBeanInvocationHandler(jmxServiceUrl, jmxObjectName)); }
/** * Return a proxy implementing all the interfaces specified that forward method invocations to the specified MBean. * * @param <T> * @param mbeanInterface * the interface the proxy should implement (the MBean should obviously also implement that interface). * @param jmxServiceUrl * the JMX service URL * @param jmxObjectName * the name the MBean has been registered to * @return a proxy implementing the specified interface and that forward method invocations to the specified MBean. * * @throws IOException * for any IO problem * @throws MalformedObjectNameException * for any JMX Naming problem * @throws MBeanException * for any MBean problem * @throws ReflectionException * for any problem related to reflection */ @SuppressWarnings("unchecked") public static <T> T getMBeanProxy(final Class<T> mbeanInterface, final String jmxServiceUrl, final String jmxObjectName) throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException, ReflectionException { return (T) Proxy.newProxyInstance(Misc.class.getClassLoader(), new Class[] { mbeanInterface }, new MBeanInvocationHandler(jmxServiceUrl, jmxObjectName)); }
/** * Return a proxy implementing all the interfaces specified that forward method invocations to the specified MBean. * * @param <T> * @param mbeanInterface * the interface the proxy should implement (the MBean should obviously also implement that interface). * @param jmxServiceUrl * the JMX service URL * @param jmxObjectName * the name the MBean has been registered to * @return a proxy implementing the specified interface and that forward method invocations to the specified MBean. * * @throws IOException * for any IO problem * @throws MalformedObjectNameException * for any JMX Naming problem * @throws MBeanException * for any MBean problem * @throws ReflectionException * for any problem related to reflection */ @SuppressWarnings("unchecked") public static <T> T getMBeanProxy(final Class<T> mbeanInterface, final String jmxServiceUrl, final String jmxObjectName) throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException, ReflectionException { return (T) Proxy.newProxyInstance(Misc.class.getClassLoader(), new Class[] { mbeanInterface }, new MBeanInvocationHandler(jmxServiceUrl, jmxObjectName)); }