java.rmi.server
Class RemoteObjectInvocationHandler

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteObjectInvocationHandler
All Implemented Interfaces:
Serializable, InvocationHandler, Remote

public class RemoteObjectInvocationHandler
extends RemoteObject
implements InvocationHandler, Remote, Serializable

Together with dynamic proxy instance, this class replaces the generated RMI stub (*_Stub) classes that (following 1.5 specification) should be no longer required. It is unusual to use the instances of this class directly in the user program. Such instances are automatically created and returned by Registry or UnicastRemoteObject methods if the remote reference is known but the corresponding stub class is not accessible.

See Also:
Registry.lookup(java.lang.String), Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteObjectInvocationHandler(RemoteRef reference)
          Construct the remote invocation handler that forwards calls to the given remote object.
 
Method Summary
 Object invoke(Object proxyInstance, Method method, Object[] parameters)
          Invoke the remote method.
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteObjectInvocationHandler

public RemoteObjectInvocationHandler(RemoteRef reference)
Construct the remote invocation handler that forwards calls to the given remote object.

Parameters:
reference - the reference to the remote object where the method calls should be forwarded.
Method Detail

invoke

public Object invoke(Object proxyInstance,
                     Method method,
                     Object[] parameters)
              throws Throwable
Invoke the remote method. When the known method is invoked on a created RMI stub proxy class, the call is delivered to this method and then transferred to the RemoteRef.invoke(Remote, Method, Object[], long) of the remote reference that was passed in constructor. The methods are handled as following:

Specified by:
invoke in interface InvocationHandler
Parameters:
proxyInstance - the instance of the proxy stub
method - the method being invoked
parameters - the method parameters
Returns:
the method return value, returned by RemoteRef.invoke
Throws:
IllegalAccessException - if the passed proxy instance does not implement Remote interface.
UnexpectedException - if remote call throws some exception, not listed in the throws clause of the method being called.
Throwable - that is thrown by remote call, if that exception is listend in the throws clause of the method being called.
See Also:
Proxy, UndeclaredThrowableException