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.