java.applet

java.awt

java.awt.color

java.awt.datatransfer

java.awt.dnd

java.awt.event

java.awt.font

java.awt.geom

java.awt.im

java.awt.im.spi

java.awt.image

java.awt.image.renderable

java.awt.print

java.beans

java.beans.beancontext

java.io

java.lang

java.lang.annotation

java.lang.instrument

java.lang.management

java.lang.ref

java.lang.reflect

java.math

java.net

java.nio

java.nio.channels

java.nio.channels.spi

java.nio.charset

java.nio.charset.spi

java.rmi

java.rmi.activation

java.rmi.dgc

java.rmi.registry

java.rmi.server

java.security

java.security.acl

java.security.cert

java.security.interfaces

java.security.spec

java.sql

java.text

java.util

java.util.concurrent

java.util.concurrent.atomic

java.util.concurrent.locks

java.util.jar

java.util.logging

java.util.prefs

java.util.regex

java.util.zip

javax.accessibility

javax.activity

javax.crypto

javax.crypto.interfaces

javax.crypto.spec

javax.imageio

javax.imageio.event

javax.imageio.metadata

javax.imageio.plugins.bmp

javax.imageio.plugins.jpeg

javax.imageio.spi

javax.imageio.stream

javax.management

javax.management.loading

javax.management.modelmbean

javax.management.monitor

javax.management.openmbean

javax.management.relation

javax.management.remote

javax.management.remote.rmi

javax.management.timer

javax.naming

javax.naming.directory

javax.naming.event

javax.naming.ldap

javax.naming.spi

javax.net

javax.net.ssl

javax.print

javax.print.attribute

javax.print.attribute.standard

javax.print.event

javax.rmi

javax.rmi.CORBA

javax.rmi.ssl

javax.security.auth

javax.security.auth.callback

javax.security.auth.kerberos

javax.security.auth.login

javax.security.auth.spi

javax.security.auth.x500

javax.security.cert

javax.security.sasl

javax.sound.midi

javax.sound.midi.spi

javax.sound.sampled

javax.sound.sampled.spi

javax.sql

javax.sql.rowset

javax.sql.rowset.serial

javax.sql.rowset.spi

javax.swing

javax.swing.border

javax.swing.colorchooser

javax.swing.event

javax.swing.filechooser

javax.swing.plaf

javax.swing.plaf.basic

javax.swing.plaf.metal

javax.swing.plaf.multi

javax.swing.plaf.synth

javax.swing.table

javax.swing.text

javax.swing.text

javax.swing.text.parser

javax.swing.text.rtf

javax.swing.tree

javax.swing.undo

javax.transaction

javax.transaction.xa

javax.xml

javax.xml.datatype

javax.xml.namespace

javax.xml.parsers

javax.xml.transform

javax.xml.transform.dom

javax.xml.transform.sax

javax.xml.transform.stream

javax.xml.validation

javax.xml.xpath

org.ietf.jgss

org.omg.CORBA

org.omg.CORBA_2_3

org.omg.CORBA_2_3.portable

org.omg.CORBA.DynAnyPackage

org.omg.CORBA.ORBPackage

org.omg.CORBA.portable

org.omg.CORBA.TypeCodePackage

org.omg.CosNaming

org.omg.CosNaming.NamingContextExtPackage

org.omg.CosNaming.NamingContextPackage

org.omg.Dynamic

org.omg.DynamicAny

org.omg.DynamicAny.DynAnyFactoryPackage

org.omg.DynamicAny.DynAnyPackage

org.omg.IOP

org.omg.IOP.CodecFactoryPackage

org.omg.IOP.CodecPackage

org.omg.Messaging

org.omg.PortableInterceptor

org.omg.PortableInterceptor.ORBInitInfoPackage

org.omg.PortableServer

org.omg.PortableServer.CurrentPackage

org.omg.PortableServer.POAManagerPackage

org.omg.PortableServer.POAPackage

org.omg.PortableServer.portable

org.omg.PortableServer.ServantLocatorPackage

org.omg.SendingContext

org.omg.stub.java.rmi

org.w3c.dom

org.w3c.dom.bootstrap

org.w3c.dom.events

org.w3c.dom.ls

org.xml.sax

org.xml.sax.ext

org.xml.sax.helpers

allclasses-frame

allclasses-noframe

constant-values

deprecated-list

help-doc

JavaTM 2 Platform
Standard Ed. 5.0

java.rmi.server
类 UnicastRemoteObject

java.lang.Object
  继承者 java.rmi.server.RemoteObject
      继承者 java.rmi.server.RemoteServer
          继承者 java.rmi.server.UnicastRemoteObject
所有已实现的接口:
Serializable, Remote
直接已知子类:
ActivationGroup

public class UnicastRemoteObject
extends RemoteServer

用于导出带 JRMP 的远程对象和获得与该远程对象通信的 stub。

对于下面的构造方法和静态 exportObject 方法,正在导出的远程对象的 stub 按以下方式获得:

  • 如果使用 UnicastRemoteObject.exportObject(Remote) 方法导出该远程对象,则加载 stub 类(通常使用 rmic 工具从远程对象的类预生成)并按以下方式构造 stub 类的实例。
    • “根类”按以下情形确定:如果远程对象的类直接实现扩展 Remote 的接口,则远程对象的类为根类;否则,根类为直接实现扩展 Remote 接口的远程对象类的最具派生能力的超类。
    • 要加载的 stub 类的名称通过连接带有后缀 "_Stub" 的根类的二进制名称确定。
    • 按使用根类的类加载器的名称加载 stub 类。该 stub 类必须扩展 RemoteStub 并且必须有公共构造方法,该构造方法有一个属于类型 RemoteRef 的参数。
    • 最后,用 RemoteRef 构造 stub 类的实例。
  • 如果无法找到适当的 stub 类,或无法加载 stub 类,或创建 stub 实例时出现问题,则抛出 StubNotFoundException

  • 对于所有其他导出方式:

    • 如果无法加载远程对象的 stub 类(如上所述)或将系统属性 java.rmi.server.ignoreStubClasses 设置为 "true"(不分大小写),则用以下属性构造 Proxy 实例:

    • 否则,将远程对象的 stub 类(如上所述)的实例用作 stub。

从以下版本开始:
JDK1.1
另请参见:
序列化表格

字段摘要
 
从类 java.rmi.server.RemoteObject 继承的字段
ref
 
构造方法摘要
protected UnicastRemoteObject()
          使用匿名端口创建并导出一个新 UnicastRemoteObject 对象。
protected UnicastRemoteObject(int port)
          使用提供的特定端口创建并导出一个新 UnicastRemoteObject 对象。
protected UnicastRemoteObject(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
          使用提供的特定端口和套接字工厂创建并导出一个新 UnicastRemoteObject 对象。
 
方法摘要
 Object clone()
          返回与初始对象不同的远程对象的克隆。
static RemoteStub exportObject(Remote obj)
          使用匿名端口导出远程对象,以便能够接收传入的调用。
static Remote exportObject(Remote obj, int port)
          使用提供的特定端口导出远程对象,以便能够接收传入的调用。
static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
          使用由给定的套接字工厂指定的传送方式导出远程对象,以便能够接收传入的调用。
static boolean unexportObject(Remote obj, boolean force)
          从 RMI 运行时移除远程对象 obj。
 
从类 java.rmi.server.RemoteServer 继承的方法
getClientHost, getLog, setLog
 
从类 java.rmi.server.RemoteObject 继承的方法
equals, getRef, hashCode, toString, toStub
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

UnicastRemoteObject

protected UnicastRemoteObject()
                       throws RemoteException
使用匿名端口创建并导出一个新 UnicastRemoteObject 对象。

抛出:
RemoteException - 如果导出对象失败
从以下版本开始:
JDK1.1

UnicastRemoteObject

protected UnicastRemoteObject(int port)
                       throws RemoteException
使用提供的特定端口创建并导出一个新 UnicastRemoteObject 对象。

参数:
port - 远程对象在其上接收调用的端口号(如果 port 为 0,则选择匿名端口)
抛出:
RemoteException - 如果导出对象失败
从以下版本开始:
1.2

UnicastRemoteObject

protected UnicastRemoteObject(int port,
                              RMIClientSocketFactory csf,
                              RMIServerSocketFactory ssf)
                       throws RemoteException
使用提供的特定端口和套接字工厂创建并导出一个新 UnicastRemoteObject 对象。

参数:
port - 远程对象在其上接收调用的端口号(如果 port 为 0,则选择匿名端口)
csf - 用于调用远程对象的客户端套接字工厂
ssf - 用于接收远程调用的服务器端套接字工厂
抛出:
RemoteException - 如果导出对象失败
从以下版本开始:
1.2
方法详细信息

clone

public Object clone()
             throws CloneNotSupportedException
返回与初始对象不同的远程对象的克隆。

覆盖:
Object 中的 clone
返回:
新的远程对象
抛出:
CloneNotSupportedException - 如果因为 RemoteException 克隆失败。
从以下版本开始:
JDK1.1
另请参见:
Cloneable

exportObject

public static RemoteStub exportObject(Remote obj)
                               throws RemoteException
使用匿名端口导出远程对象,以便能够接收传入的调用。

参数:
obj - 要导出的远程对象
返回:
远程对象的 stub
抛出:
RemoteException - 如果导出失败
从以下版本开始:
JDK1.1

exportObject

public static Remote exportObject(Remote obj,
                                  int port)
                           throws RemoteException
使用提供的特定端口导出远程对象,以便能够接收传入的调用。

参数:
obj - 要导出的远程对象
port - 要在其上导出对象的端口
返回:
远程对象的 stub
抛出:
RemoteException - 如果导出失败
从以下版本开始:
1.2

exportObject

public static Remote exportObject(Remote obj,
                                  int port,
                                  RMIClientSocketFactory csf,
                                  RMIServerSocketFactory ssf)
                           throws RemoteException
使用由给定的套接字工厂指定的传送方式导出远程对象,以便能够接收传入的调用。

参数:
obj - 要导出的远程对象
port - 在其上导出对象的端口
csf - 用于调用远程对象的客户端套接字工厂
ssf - 用于接收远程调用的服务器端套接字工厂
返回:
远程对象的 stub
抛出:
RemoteException - 如果导出失败
从以下版本开始:
1.2

unexportObject

public static boolean unexportObject(Remote obj,
                                     boolean force)
                              throws NoSuchObjectException
从 RMI 运行时移除远程对象 obj。如果成功,该对象可以不再接受传入的 RMI 调用。如果 force 参数为 true,则不会强行导出该对象,即使挂起远程对象的调用或远程对象仍在进行调用也一样。如果 force 参数为 false,则只有在未挂起且未调用对象的情况下才不会导出该对象。

参数:
obj - 将不导出的远程对象
force - 如果为 true,则即便挂起或正在进行调用也不导出对象;如果为 false,则只有在不挂起或未进行调用时才不导出对象
返回:
如果操作成功,则返回 true;否则返回 false
抛出:
NoSuchObjectException - 如果当前未导出远程对象
从以下版本开始:
1.2

JavaTM 2 Platform
Standard Ed. 5.0

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策