org.jmx4odp.j4oNet
Class ProxyInvocationHandler

java.lang.Object
  extended by org.jmx4odp.j4oNet.ProxyInvocationHandler
All Implemented Interfaces:
java.io.Serializable, java.lang.reflect.InvocationHandler

public class ProxyInvocationHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, java.io.Serializable

This handles calls from the dynamically generated proxy class created by org.jmx4odp.j4oNet.ProxyManager

Author:
Lucas McGregor
See Also:
ProxyManager, Serialized Form

Constructor Summary
ProxyInvocationHandler(JmxServiceObj jso)
          Creates new ProxyInvocationHandler If the JmxServiceObj contains a non-null MBeanServer, it will be set as the proxy's MBeanServer.
ProxyInvocationHandler(JmxServiceObj jso, MBeanServerInt mbs)
          Creates new ProxyInvocationHandler It set's the proxy MBeanServerInt to the one passed in.
 
Method Summary
 void connect()
          Use the JSO to rebuild the MBeanServerInt and get a new connection
 JmxServiceObj createNewInstance(java.lang.String name)
          create a new instance of the MBean described in the JmxServiceObj.getClassName() on the proxied agent.
 void disconnect()
          If the remote connection to the agent represented by the JmxServiceObj is not null, then close the current one.
protected  void finalize()
           
 JmxServiceObj getJmxServiveObj()
           
 MBeanServerInt getMBeanServerInt()
           
 javax.management.ObjectInstance getObjectInstance()
          If there is an ObjectInstance in the JmxServiceObj, it will return this, else it will try to aquire an ObjectInstance from the MBeanServerInt via the jmxServiceObj.getObjectName(), else it will return a null
 java.lang.Object invoke(java.lang.Object proxyObj, java.lang.reflect.Method method, java.lang.Object[] args)
           
 void setJmxServiceObj(JmxServiceObj jso)
          Sets the JmxServiceObject to this new one.
 void setMBeanServerInt(MBeanServerInt mbsi)
          Over writes the current MBeanServerInt with the new one.
 void unregisterMBean()
          unregister the instance of the MBean described in the JmxServiceObj.getObjectName() on the proxied agent.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyInvocationHandler

public ProxyInvocationHandler(JmxServiceObj jso)
                       throws java.lang.Exception
Creates new ProxyInvocationHandler If the JmxServiceObj contains a non-null MBeanServer, it will be set as the proxy's MBeanServer. Otherwise it will try to establish a connection to the remote adaptor described by the the JmxServiceObj.

Throws:
java.lang.Exception

ProxyInvocationHandler

public ProxyInvocationHandler(JmxServiceObj jso,
                              MBeanServerInt mbs)
                       throws java.lang.Exception
Creates new ProxyInvocationHandler It set's the proxy MBeanServerInt to the one passed in.

Throws:
java.lang.Exception
Method Detail

setMBeanServerInt

public void setMBeanServerInt(MBeanServerInt mbsi)
Over writes the current MBeanServerInt with the new one. Any connections would either have to be explictly closed first, or left to the garbage collector as this method simply over writes.


getMBeanServerInt

public MBeanServerInt getMBeanServerInt()

setJmxServiceObj

public void setJmxServiceObj(JmxServiceObj jso)
                      throws java.lang.Exception
Sets the JmxServiceObject to this new one. It then over writes the current MBeanServerInt with the new one from the JmxServiceObject. Any connections would either have to be explictly closed first, or left to the garbage collector as this method simply over writes.

Throws:
java.lang.Exception

getJmxServiveObj

public JmxServiceObj getJmxServiveObj()

disconnect

public void disconnect()
If the remote connection to the agent represented by the JmxServiceObj is not null, then close the current one.


connect

public void connect()
             throws java.lang.Exception
Use the JSO to rebuild the MBeanServerInt and get a new connection

Throws:
java.lang.Exception

createNewInstance

public JmxServiceObj createNewInstance(java.lang.String name)
                                throws java.lang.Exception
create a new instance of the MBean described in the JmxServiceObj.getClassName() on the proxied agent.

Throws:
java.lang.Exception

unregisterMBean

public void unregisterMBean()
                     throws java.lang.Exception
unregister the instance of the MBean described in the JmxServiceObj.getObjectName() on the proxied agent.

Throws:
java.lang.Exception

getObjectInstance

public javax.management.ObjectInstance getObjectInstance()
                                                  throws java.lang.Exception
If there is an ObjectInstance in the JmxServiceObj, it will return this, else it will try to aquire an ObjectInstance from the MBeanServerInt via the jmxServiceObj.getObjectName(), else it will return a null

Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(java.lang.Object proxyObj,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable