Class RemoteObjectInvocationHandler
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteObjectInvocationHandler
- All Implemented Interfaces:
Serializable, InvocationHandler, Remote
An implementation of the
InvocationHandler interface for
use with Java Remote Method Invocation (Java RMI). This invocation
handler can be used in conjunction with a dynamic proxy instance as a
replacement for a pregenerated stub class.
Applications are not expected to use this class directly. A remote
object exported to use a dynamic proxy with UnicastRemoteObject
has an instance of this class as that proxy's invocation handler.
- Since:
- 1.5
- See Also:
-
Field Summary
Fields declared in class RemoteObject
ref -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newRemoteObjectInvocationHandlerconstructed with the specifiedRemoteRef. -
Method Summary
Methods declared in class RemoteObject
equals, getRef, hashCode, toString, toStubModifier and TypeMethodDescriptionbooleanCompares two remote objects for equality.getRef()Returns the remote reference for the remote object.inthashCode()Returns a hashcode for a remote object.toString()Returns a String that represents the value of this remote object.static RemoteReturns the stub for the remote objectobjpassed as a parameter.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
RemoteObjectInvocationHandler
Creates a newRemoteObjectInvocationHandlerconstructed with the specifiedRemoteRef.- Parameters:
ref- the remote ref- Throws:
NullPointerException- ifrefisnull
-
-
Method Details
-
invoke
Processes a method invocation made on the encapsulating proxy instance,proxy, and returns the result.RemoteObjectInvocationHandlerimplements this method as follows:If
methodis one of the following methods, it is processed as described below:Object.hashCode: Returns the hash code value for the proxy.Object.equals: Returnstrueif the argument (args[0]) is an instance of a dynamic proxy class and this invocation handler is equal to the invocation handler of that argument, and returnsfalseotherwise.Object.toString: Returns a string representation of the proxy.
If
methodoverridesObject.finalize, it is ignored.Otherwise, a remote call is made as follows:
- If
proxyis not an instance of the interfaceRemote, then anIllegalArgumentExceptionis thrown. - Otherwise, the
invokemethod is invoked on this invocation handler'sRemoteRef, passingproxy,method,args, and the method hash (defined in section 8.3 of the "Java Remote Method Invocation (RMI) Specification") formethod, and the result is returned. - If an exception is thrown by
RemoteRef.invokeand that exception is a checked exception that is not assignable to any exception in thethrowsclause of the method implemented by theproxy's class, then that exception is wrapped in anUnexpectedExceptionand the wrapped exception is thrown. Otherwise, the exception thrown byinvokeis thrown by this method.
The semantics of this method are unspecified if the arguments could not have been produced by an instance of some valid dynamic proxy class containing this invocation handler.
- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- the proxy instance that the method was invoked onmethod- theMethodinstance corresponding to the interface method invoked on the proxy instanceargs- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornullif the method takes no arguments- Returns:
- the value to return from the method invocation on the proxy instance
- Throws:
Throwable- the exception to throw from the method invocation on the proxy instance- See Also:
-