- java.lang.Object
-
- java.rmi.server.RemoteObject
-
- java.rmi.server.RemoteObjectInvocationHandler
-
- All Implemented Interfaces:
- Serializable, InvocationHandler, Remote
public class RemoteObjectInvocationHandler extends RemoteObject implements InvocationHandler
An implementation of theInvocationHandler
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
orActivatable
has an instance of this class as that proxy's invocation handler.- Since:
- 1.5
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.rmi.server.RemoteObject
ref
-
-
Constructor Summary
Constructors Constructor and Description RemoteObjectInvocationHandler(RemoteRef ref)
Creates a newRemoteObjectInvocationHandler
constructed with the specifiedRemoteRef
.
-
Method Summary
Methods Modifier and Type Method and Description Object
invoke(Object proxy, Method method, Object[] args)
Processes a method invocation made on the encapsulating proxy instance,proxy
, and returns the result.
-
-
-
Constructor Detail
-
RemoteObjectInvocationHandler
public RemoteObjectInvocationHandler(RemoteRef ref)
Creates a newRemoteObjectInvocationHandler
constructed with the specifiedRemoteRef
.- Parameters:
ref
- the remote ref- Throws:
NullPointerException
- ifref
isnull
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Processes a method invocation made on the encapsulating proxy instance,proxy
, and returns the result.RemoteObjectInvocationHandler
implements this method as follows:If
method
is one of the following methods, it is processed as described below:Object.hashCode
: Returns the hash code value for the proxy.Object.equals
: Returnstrue
if 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 returnsfalse
otherwise.Object.toString
: Returns a string representation of the proxy.
Otherwise, a remote call is made as follows:
- If
proxy
is not an instance of the interfaceRemote
, then anIllegalArgumentException
is thrown. - Otherwise, the
invoke
method 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.invoke
and that exception is a checked exception that is not assignable to any exception in thethrows
clause of the method implemented by theproxy
's class, then that exception is wrapped in anUnexpectedException
and the wrapped exception is thrown. Otherwise, the exception thrown byinvoke
is 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:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- the proxy instance that the method was invoked onmethod
- theMethod
instance 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, ornull
if 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:
UndeclaredThrowableException
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/11/2024 04:26:10 Cette version de la page est en cache (à la date du 22/11/2024 04:26:10) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 25/07/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/rmi/server/RemoteObjectInvocationHandler.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.