package rmi; import java.net.*; /** RMI skeleton

A skeleton encapsulates a multithreaded TCP server. The server's clients are intended to be RMI stubs created using the Stub class.

The skeleton class is parametrized by a type variable. This type variable should be instantiated with an interface. The skeleton will accept from the stub requests for calls to the methods of this interface. It will then forward those requests to an object. The object is specified when the skeleton is constructed, and must implement the remote interface. Each method in the interface should be marked as throwing RMIException, in addition to any other exceptions that the user desires.

Exceptions may occur at the top level in the listening and service threads. The skeleton's response to these exceptions can be customized by deriving a class from Skeleton and overriding listen_error or service_error. */ public class Skeleton { /** Creates a Skeleton with no initial server address. The address will be determined by the system when start is called. Equivalent to using Skeleton(null).

This constructor is for skeletons that will not be used for bootstrapping RMI - those that therefore do not require a well-known port. @param c An object representing the class of the interface for which the skeleton server is to handle method call requests. @param server An object implementing said interface. Requests for method calls are forwarded by the skeleton to this object. @throws Error If c does not represent a remote interface - an interface whose methods are all marked as throwing RMIException. @throws NullPointerException If either of c or server is null. */ public Skeleton(Class c, T server) { throw new UnsupportedOperationException("not implemented"); } /** Creates a Skeleton with the given initial server address.

This constructor should be used when the port number is significant. @param c An object representing the class of the interface for which the skeleton server is to handle method call requests. @param server An object implementing said interface. Requests for method calls are forwarded by the skeleton to this object. @param address The address at which the skeleton is to run. If null, the address will be chosen by the system when start is called. @throws Error If c does not represent a remote interface - an interface whose methods are all marked as throwing RMIException. @throws NullPointerException If either of c or server is null. */ public Skeleton(Class c, T server, InetSocketAddress address) { throw new UnsupportedOperationException("not implemented"); } /** Called when the listening thread exits.

The listening thread may exit due to a top-level exception, or due to a call to stop.

When this method is called, the calling thread owns the lock on the Skeleton object. Care must be taken to avoid deadlocks when calling start or stop from different threads during this call.

The default implementation does nothing. @param cause The exception that stopped the skeleton, or null if the skeleton stopped normally. */ protected void stopped(Throwable cause) { } /** Called when an exception occurs at the top level in the listening thread.

The intent of this method is to allow the user to report exceptions in the listening thread to another thread, by a mechanism of the user's choosing. The user may also ignore the exceptions. The default implementation simply stops the server. The user should not use this method to stop the skeleton. The exception will again be provided as the argument to stopped, which will be called later. @param exception The exception that occurred. @return true if the server is to resume accepting connections, false if the server is to shut down. */ protected boolean listen_error(Exception exception) { return false; } /** Called when an exception occurs at the top level in a service thread.

The default implementation does nothing. @param exception The exception that occurred. */ protected void service_error(RMIException exception) { } /** Starts the skeleton server.

A thread is created to listen for connection requests, and the method returns immediately. Additional threads are created when connections are accepted. The network address used for the server is determined by which constructor was used to create the Skeleton object. @throws RMIException When the listening socket cannot be created or bound, when the listening thread cannot be created, or when the server has already been started and has not since stopped. */ public synchronized void start() throws RMIException { throw new UnsupportedOperationException("not implemented"); } /** Stops the skeleton server, if it is already running.

The listening thread terminates. Threads created to service connections may continue running until their invocations of the service method return. The server stops at some later time; the method stopped is called at that point. The server may then be restarted. */ public synchronized void stop() { throw new UnsupportedOperationException("not implemented"); } }