javax.rmi
Class PortableRemoteObject

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.rmi.PortableRemoteObject

public class PortableRemoteObject
extends Object sample code for java.lang.Object definition code for java.lang.Object

Server implementation objects may either inherit from javax.rmi.PortableRemoteObject or they may implement a remote interface and then use the exportObject method to register themselves as a server object. The toStub method takes a server implementation and returns a stub that can be used to access that server object. The connect method makes a Remote object ready for remote communication. The unexportObject method is used to deregister a server object, allowing it to become available for garbage collection. The narrow method takes an object reference or abstract interface type and attempts to narrow it to conform to the given interface. If the operation is successful the result will be an object of the specified type, otherwise an exception will be thrown.


Constructor Summary
protected PortableRemoteObject sample code for javax.rmi.PortableRemoteObject.PortableRemoteObject() definition code for javax.rmi.PortableRemoteObject.PortableRemoteObject() ()
          Initializes the object by calling exportObject(this).
 
Method Summary
static void connect sample code for javax.rmi.PortableRemoteObject.connect(java.rmi.Remote, java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.connect(java.rmi.Remote, java.rmi.Remote) (Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  target, Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  source)
          Makes a Remote object ready for remote communication.
static void exportObject sample code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote) (Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          Makes a server object ready to receive remote calls.
static Object sample code for java.lang.Object definition code for java.lang.Object narrow sample code for javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class) definition code for javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class) (Object sample code for java.lang.Object definition code for java.lang.Object  narrowFrom, Class sample code for java.lang.Class definition code for java.lang.Class  narrowTo)
          Checks to ensure that an object of a remote or abstract interface type can be cast to a desired type.
static Remote sample code for java.rmi.Remote definition code for java.rmi.Remote toStub sample code for javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote) (Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          Returns a stub for the given server object.
static void unexportObject sample code for javax.rmi.PortableRemoteObject.unexportObject(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.unexportObject(java.rmi.Remote) (Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          Deregisters a server object from the runtime, allowing the object to become available for garbage collection.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PortableRemoteObject sample code for javax.rmi.PortableRemoteObject() definition code for javax.rmi.PortableRemoteObject()

protected PortableRemoteObject()
                        throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException 
Initializes the object by calling exportObject(this).

Throws:
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if export fails.
Method Detail

exportObject sample code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote)

public static void exportObject(Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
                         throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException 
Makes a server object ready to receive remote calls. Note that subclasses of PortableRemoteObject do not need to call this method, as it is called by the constructor.

Parameters:
obj - the server object to export.
Throws:
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if export fails.

toStub sample code for javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.toStub(java.rmi.Remote)

public static Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  toStub(Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
                     throws NoSuchObjectException sample code for java.rmi.NoSuchObjectException definition code for java.rmi.NoSuchObjectException 
Returns a stub for the given server object.

Parameters:
obj - the server object for which a stub is required. Must either be a subclass of PortableRemoteObject or have been previously the target of a call to exportObject(java.rmi.Remote) sample code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.exportObject(java.rmi.Remote) .
Returns:
the most derived stub for the object.
Throws:
NoSuchObjectException sample code for java.rmi.NoSuchObjectException definition code for java.rmi.NoSuchObjectException - if a stub cannot be located for the given server object.

unexportObject sample code for javax.rmi.PortableRemoteObject.unexportObject(java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.unexportObject(java.rmi.Remote)

public static void unexportObject(Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
                           throws NoSuchObjectException sample code for java.rmi.NoSuchObjectException definition code for java.rmi.NoSuchObjectException 
Deregisters a server object from the runtime, allowing the object to become available for garbage collection.

Parameters:
obj - the object to unexport.
Throws:
NoSuchObjectException sample code for java.rmi.NoSuchObjectException definition code for java.rmi.NoSuchObjectException - if the remote object is not currently exported.

narrow sample code for javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class) definition code for javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)

public static Object sample code for java.lang.Object definition code for java.lang.Object  narrow(Object sample code for java.lang.Object definition code for java.lang.Object  narrowFrom,
                            Class sample code for java.lang.Class definition code for java.lang.Class  narrowTo)
                     throws ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException 
Checks to ensure that an object of a remote or abstract interface type can be cast to a desired type.

Parameters:
narrowFrom - the object to check.
narrowTo - the desired type.
Returns:
an object which can be cast to the desired type.
Throws:
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if narrowFrom cannot be cast to narrowTo.

connect sample code for javax.rmi.PortableRemoteObject.connect(java.rmi.Remote, java.rmi.Remote) definition code for javax.rmi.PortableRemoteObject.connect(java.rmi.Remote, java.rmi.Remote)

public static void connect(Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  target,
                           Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  source)
                    throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException 
Makes a Remote object ready for remote communication. This normally happens implicitly when the object is sent or received as an argument on a remote method call, but in some circumstances it is useful to perform this action by making an explicit call. See the Stub#connect method for more information.

Parameters:
target - the object to connect.
source - a previously connected object.
Throws:
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if source is not connected or if target is already connected to a different ORB than source.