server
Class RemoteServer2

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--server.RemoteServer2
All Implemented Interfaces:
java.rmi.Remote, RemoteServerInterface, java.io.Serializable

public class RemoteServer2
extends java.rmi.server.UnicastRemoteObject
implements RemoteServerInterface

Class RemoteServer2 is a simple illustration of a remote server that uses RMI communication. This version of the server is hard wired to run on the Windows host thyme2.csc.calpoly.edu.

The server provides three typical methods to a client: receiveClientInput, compute, and getServerOutput. These methods are described further in their respective method documentation.

The execution of the RemoteServer main method proceeds as follows:

  1. Set up a Java security manager if there isn't one already running on the server machine.
  2. Allocate a remote server instance and bind it in the host's rmi registry. This makes the server available to requesting clients.
See the example Client2 class for a description of how a client uses this server's services. See RemoteServer for an example server that runs on a Windows host. (The only differences between the UNIX versus Windows servers are the hard-wired host machine name and a simple change in the compute method that indicates which server is running.)

See Also:
Serialized Form

Field Summary
protected  ClientDataInterface clientData
          Local copy of client input for computing with
protected  int serverOutput
          Value computed by the server
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteServer2()
          Construct this by calling the parent constructor.
 
Method Summary
 void compute()
          Perform some computation using the client input.
 java.lang.Object getServerOutput()
          Return computation results back to the client, when the client calls for it.
static void main(java.lang.String[] args)
          Perform necessary setup for remote execution.
 void receiveClientInput(ClientDataInterface clientData)
          Receive some input from the client.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

clientData

protected ClientDataInterface clientData
Local copy of client input for computing with

serverOutput

protected int serverOutput
Value computed by the server
Constructor Detail

RemoteServer2

public RemoteServer2()
              throws java.rmi.RemoteException
Construct this by calling the parent constructor.
Method Detail

receiveClientInput

public void receiveClientInput(ClientDataInterface clientData)
                        throws java.rmi.RemoteException
Receive some input from the client. Store a local copy for computation use.
Specified by:
receiveClientInput in interface RemoteServerInterface

compute

public void compute()
             throws java.rmi.RemoteException
Perform some computation using the client input. In this case, we simply add 2 to the numeric input value.
Specified by:
compute in interface RemoteServerInterface

getServerOutput

public java.lang.Object getServerOutput()
                                 throws java.rmi.RemoteException
Return computation results back to the client, when the client calls for it.
Specified by:
getServerOutput in interface RemoteServerInterface

main

public static void main(java.lang.String[] args)
Perform necessary setup for remote execution.