org.objectweb.carol.irmi
Class Server

java.lang.Object
  extended by java.lang.Thread
      extended by org.objectweb.carol.irmi.Server
All Implemented Interfaces:
Runnable, Constants

public class Server
extends Thread
implements Constants

The Server class manages exported Remote objects and listens for connections from remote references. It also contains static methods that the Ref class uses to make remote invocations.

Author:
Rafael H. Schloming <rhs@mit.edu>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.objectweb.carol.irmi.Constants
DGC_PING, METHOD_CALL, METHOD_ERROR, METHOD_RESULT, SYSTEM_ERROR
 
Constructor Summary
Server()
          Constructs a Server instance that will bind to any available port and does not have any Interceptors.
Server(ClientInterceptor clint, Interceptor srvint)
          Constructs a Server instance that will bind to any available port and use the given client and server Interceptors.
Server(int port, ClientInterceptor clint, Interceptor srvint)
          Construcst a Server instance with the specified port, client, and server Interceptors.
 
Method Summary
 void export(Remote object)
          Exports the given Remote object.
 ClassLoader getLoader(ObjID oid)
          Return the ClassLoader used for deserializing arguments to methods of the exported object mapped to the given oid or null if there is none.
 Remote getObject(ObjID oid)
          Return the exported object for the given oid or null if there is none.
 ObjID getOID(Remote obj)
          Return the ObjID for the given Remote object or null if there is none.
static Collection getServers()
          Returns all the Server instances for this JVM.
 Skeleton getSkel(Remote obj)
          Construct and return a Skeleton for the given Remote object.
 RemoteStub getStub(Remote obj)
          Converts the given Remote object to a RemoteStub instance.
 void run()
          Accepts connections and launches Handler threads.
 boolean unexport(ObjID oid)
          Unexports the Remote object associated with the given ObjID if it is being exported by this Server.
 boolean unexport(Remote obj)
          Unexports the given Remote object if it is being exported by this Server.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Server

public Server(int port,
              ClientInterceptor clint,
              Interceptor srvint)
Construcst a Server instance with the specified port, client, and server Interceptors. If port is zero then any available port will be chosen.

Parameters:
port - the port for the server to bind to
clint - the client Interceptor or null
srvint - the server Interceptor or null

Server

public Server(ClientInterceptor clint,
              Interceptor srvint)
Constructs a Server instance that will bind to any available port and use the given client and server Interceptors.

Parameters:
clint - the client Interceptor
srvint - the server Interceptor

Server

public Server()
Constructs a Server instance that will bind to any available port and does not have any Interceptors.

Method Detail

getServers

public static Collection getServers()
Returns all the Server instances for this JVM.

Returns:
all the Server instances for this JVM

run

public void run()
Accepts connections and launches Handler threads.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getObject

public Remote getObject(ObjID oid)
Return the exported object for the given oid or null if there is none.

Parameters:
oid - the oid of an exported object
Returns:
the exported object or null if there is none

getOID

public ObjID getOID(Remote obj)
Return the ObjID for the given Remote object or null if there is none.

Parameters:
obj - an exported object
Returns:
the ObjID assigned to the exported object, or null if there is none

getLoader

public ClassLoader getLoader(ObjID oid)
Return the ClassLoader used for deserializing arguments to methods of the exported object mapped to the given oid or null if there is none.

Parameters:
oid - the oid of an exported object
Returns:
the ClassLoader used for deserializing arguments to methods of the exported object mapped to the given oid or null if there is none

getSkel

public Skeleton getSkel(Remote obj)
Construct and return a Skeleton for the given Remote object.

Parameters:
obj - a Remote object
Returns:
the Skeleton for obj

getStub

public RemoteStub getStub(Remote obj)
Converts the given Remote object to a RemoteStub instance. This may involve nothing if the object is already a stub, or it may involve search for an appropriate stub class and constructing an instance of it.

Parameters:
obj - the Remote object
Returns:
a RemoteStub for obj

export

public void export(Remote object)
            throws ExportException
Exports the given Remote object.

Parameters:
object - the object to export
Throws:
ExportException - when there is an error

unexport

public boolean unexport(Remote obj)
Unexports the given Remote object if it is being exported by this Server.

Parameters:
obj - the object to unexport
Returns:
true iff the object was unexported

unexport

public boolean unexport(ObjID oid)
Unexports the Remote object associated with the given ObjID if it is being exported by this Server.

Parameters:
oid - the ObjID of the Remote object to be unexported
Returns:
true iff the object was unexported