java.rmi.server
Class RemoteObjectInvocationHandler
java.lang.Object
java.rmi.server.RemoteObject
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
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.
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:
- The toString() method is delegated to the passed proxy instance.
- The .equals method only returns true if the passed object is an
instance of proxy class and its invocation handler is equal to this
invocation handles.
- The .hashCode returns the hashCode of this invocation handler (if the.
- All other methods are converted to remote calls and forwarded to the
remote reference.
- Specified by:
invoke
in interface InvocationHandler
- Parameters:
proxyInstance
- the instance of the proxy stubmethod
- the method being invokedparameters
- 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