public class RemoteObjectInvocationHandler extends RemoteObject implements InvocationHandler
InvocationHandler接口的一个实现(java RMI)。这个调用处理程序可用于在一个动态代理实例连接作为一个预先生成的存根类置换。
应用程序不直接使用这个类。一个远程对象的出口使用动态代理UnicastRemoteObject或Activatable具有这个类的实例作为代理的调用处理程序。
ref| Constructor and Description |
|---|
RemoteObjectInvocationHandler(RemoteRef ref)
创建一个新的
RemoteObjectInvocationHandler与指定的
RemoteRef构造。
|
public RemoteObjectInvocationHandler(RemoteRef ref)
RemoteObjectInvocationHandler与指定的
RemoteRef构造。
ref -远程参考
null
ref
NullPointerException
public Object invoke(Object proxy, 方法 method, Object[] args) throws Throwable
proxy代理实例,方法调用,并返回结果。
RemoteObjectInvocationHandler实现此方法如下:
如果method是下列方法之一,它是描述如下处理:
Object.hashCode:返回代理的哈希码值。Object.equals:返回true如果参数(args[0])是一个动态代理类的实例,调用处理程序是相等的参数调用处理程序,并返回false否则。Object.toString:返回一个字符串表示的代理。否则,一个远程调用如下:
proxy是不是接口的Remote实例,然后IllegalArgumentException抛出。invoke方法在调用处理程序的RemoteRef,通过proxy,method,args调用,方法和散列(在“java远程方法调用(RMI)8.3节定义为method规范”),并返回结果。RemoteRef.invoke,抛出的异常是一个例外,是异常的,是不可转让的proxy的类中实现的方法的throws条款的任何异常,然后异常是包裹在一个UnexpectedException和包裹被抛出异常。否则,该方法抛出的异常抛出invoke。这种方法的语义是未指定的,如果参数不能由包含此调用处理程序的一些有效的动态代理类的实例产生。
invoke 接口
InvocationHandler
proxy -代理实例,调用的方法
method代理实例的
方法实例
args -包含在方法上通过代理实例调用的实参的值对象的数组,或
null如果方法不需要参数
Throwable -把从方法上代理实例调用的例外
UndeclaredThrowableException
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.