- java.lang.Object
-
- javax.management.remote.rmi.RMIServerImpl
-
- 实现的所有接口
-
Closeable,AutoCloseable,Remote,RMIServer
- 已知直接子类:
-
RMIIIOPServerImpl,RMIJRMPServerImpl
public abstract class RMIServerImpl extends Object implements Closeable, RMIServer
表示连接器服务器的RMI对象。 远程客户端可以使用
newClient(Object)方法建立连接。 此方法返回表示连接的RMI对象。用户代码通常不直接引用此类。 RMI连接服务器通常使用类
RMIConnectorServer创建。 远程客户端通常使用JMXConnectorFactory或实例化RMIConnector创建连接。这是一个抽象类。 具体子类定义客户端连接对象的详细信息。
- 从以下版本开始:
- 1.5
-
-
构造方法摘要
构造方法 构造器 描述 RMIServerImpl(Map<String,?> env)构造一个新的RMIServerImpl。
-
方法摘要
所有方法 实例方法 抽象方法 具体的方法 变量和类型 方法 描述 protected voidclientClosed(RMIConnection client)关闭由makeClient创建的客户端连接时调用的方法。voidclose()关闭此连接服务器。protected abstract voidcloseClient(RMIConnection client)关闭由makeClient创建的客户端连接。protected abstract voidcloseServer()由close()调用以关闭连接器服务器。protected abstract voidexport()导出此RMI对象。ClassLoadergetDefaultClassLoader()获取此连接器服务器使用的默认值ClassLoader。MBeanServergetMBeanServer()此连接器服务器所连接的MBeanServer。protected abstract StringgetProtocol()返回此对象的协议字符串。protected abstract RMIConnectionmakeClient(String connectionId, Subject subject)创建新的客户端连接。RMIConnectionnewClient(Object credentials)创建新的客户端连接。voidsetDefaultClassLoader(ClassLoader cl)为此连接器服务器设置默认值ClassLoader。voidsetMBeanServer(MBeanServer mbs)设置此连接器服务器所连接的MBeanServer。abstract RemotetoStub()返回此服务器对象的远程存根。-
声明方法的类 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
声明方法的接口 javax.management.remote.rmi.RMIServer
getVersion
-
-
-
-
方法详细信息
-
export
protected abstract void export() throws IOException导出此RMI对象。
- 异常
-
IOException- 如果无法导出此RMI对象。
-
toStub
public abstract Remote toStub() throws IOException
返回此服务器对象的远程存根。- 结果
- 一个遥远的存根。
- 异常
-
IOException- 如果无法获取存根 - 例如,尚未导出RMIServerImpl。
-
setDefaultClassLoader
public void setDefaultClassLoader(ClassLoader cl)
为此连接器服务器设置默认值
ClassLoader。 新客户端连接将使用此类加载器。 现有客户端连接不受影响。- 参数
-
cl- 此连接器服务器将使用的新ClassLoader。 - 另请参见:
-
getDefaultClassLoader()
-
getDefaultClassLoader
public ClassLoader getDefaultClassLoader()
获取此连接器服务器使用的默认值
ClassLoader。- 结果
-
此连接器服务器使用的默认值
ClassLoader。 - 另请参见:
-
setDefaultClassLoader(java.lang.ClassLoader)
-
setMBeanServer
public void setMBeanServer(MBeanServer mbs)
设置此连接器服务器所连接的
MBeanServer。 新的客户端连接将与此MBeanServer交互。 现有客户端连接不受影响。- 参数
-
mbs- 新的MBeanServer。 可以为null,但只要是新的客户端连接就会被拒绝。 - 另请参见:
-
getMBeanServer()
-
getMBeanServer
public MBeanServer getMBeanServer()
此连接器服务器所连接的
MBeanServer。 这是在此对象上传递给setMBeanServer(javax.management.MBeanServer)的最后一个值,如果从未调用过该方法,则返回null。- 结果
-
连接器所连接的
MBeanServer。 - 另请参见:
-
setMBeanServer(javax.management.MBeanServer)
-
newClient
public RMIConnection newClient(Object credentials) throws IOException
创建新的客户端连接。 此方法调用
makeClient并将返回的客户端连接对象添加到内部列表。 当通过其close()方法关闭此RMIServerImpl,将调用列表中剩余的每个对象的close()方法。客户端连接对象位于此内部列表中的事实不会阻止它被垃圾回收。
- Specified by:
-
newClient在界面RMIServer - 参数
-
credentials- 此对象指定要传递到服务器的用户定义凭据,以便在创建RMIConnection之前对调用方进行身份验证。 可以为null。 - 结果
-
新创建的
RMIConnection。 这通常是由makeClient创建的对象,但实现可以选择将该对象包装在另一个实现RMIConnection对象中。 - 异常
-
IOException- 如果无法创建或导出新客户端对象。 -
SecurityException- 如果给定凭据不允许服务器成功验证用户。 -
IllegalStateException- 如果getMBeanServer()为空。
-
makeClient
protected abstract RMIConnection makeClient(String connectionId, Subject subject) throws IOException
创建新的客户端连接。 该方法由公共方法
newClient(Object)调用 。- 参数
-
connectionId- 新连接的ID。 此连接器服务器打开的每个连接都将具有不同的ID。 如果此参数为null,则不指定行为。 -
subject- 经过验证的主题。 可以为null。 - 结果
-
新创建的
RMIConnection。 - 异常
-
IOException- 如果无法创建或导出新客户端对象。
-
closeClient
protected abstract void closeClient(RMIConnection client) throws IOException
关闭由
makeClient创建的客户端连接。- 参数
-
client- 先前由makeClient返回的连接,之前未调用closeClient方法。 如果违反这些条件,则行为未指定,包括client为空的情况。 - 异常
-
IOException- 如果无法关闭客户端连接。
-
getProtocol
protected abstract String getProtocol()
返回此对象的协议字符串。 RMI / JRMP的字符串为
rmi。- 结果
- 此对象的协议字符串。
-
clientClosed
protected void clientClosed(RMIConnection client) throws IOException
关闭由
makeClient创建的客户端连接时调用的方法。 定义makeClient的子类必须安排在调用结果对象的close方法时调用此方法。 这使它可以从RMIServerImpl的连接列表中删除。client不在该列表中不是错误。从连接列表中删除
client后,此方法调用closeClient(client)。- 参数
-
client- 已关闭的客户端连接。 - 异常
-
IOException- 如果closeClient(javax.management.remote.rmi.RMIConnection)抛出此异常。 -
NullPointerException- 如果client为空。
-
close
public void close() throws IOException关闭此连接服务器。 此方法首先调用
closeServer()方法,以便不接受新的客户端连接。 然后,对于makeClient返回的每个剩余的RMIConnection对象, 调用其close方法。未指定多次调用此方法时的行为。
如果
closeServer()抛出IOException,则各个连接仍然关闭,然后从此方法抛出IOException。如果
closeServer()正常返回但一个或多个单独的连接抛出IOException,则在关闭所有连接后,将从此方法抛出其中一个IOException。 如果多个连接抛出IOException,则未指定从此方法抛出哪个连接。- Specified by:
-
close接口AutoCloseable - Specified by:
-
close在界面Closeable - 异常
-
IOException- 如果closeServer()或其中一个RMIConnection.close()电话投掷IOException。
-
closeServer
protected abstract void closeServer() throws IOException由
close()调用以关闭连接器服务器。 从此方法返回后,连接器服务器不能接受任何新连接。- 异常
-
IOException- 如果尝试关闭连接器服务器失败。
-
-