server
Class RemoteServerWithDisplay

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

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

Class RemoteServerWithDisplay is a version the RemoteServer class that adds a simple GUI display. The point is to illustrate that a remote server can have its own GUI, including client-invoked methods that update the display.

See Also:
Serialized Form

Field Summary
protected  ClientDataInterface clientData
          Local copy of client input for computing with
protected static javax.swing.JFrame frame
          JFrame for the display window
protected  int serverOutput
          Value computed by the server
protected static javax.swing.JTextField textField
          Text field to display the received client data
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteServerWithDisplay()
          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)
          Set up the display and perform necessary setup for remote execution.
 void receiveClientInput(ClientDataInterface clientData)
          Receive some input from the client.
protected static void setupDisplay()
          Set up the display as a JFrame with a labled, unediable text field.
 
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

textField

protected static javax.swing.JTextField textField
Text field to display the received client data

frame

protected static javax.swing.JFrame frame
JFrame for the display window
Constructor Detail

RemoteServerWithDisplay

public RemoteServerWithDisplay()
                        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. Also, display the data in the server's display window.
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 1 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

setupDisplay

protected static void setupDisplay()
                            throws java.rmi.RemoteException
Set up the display as a JFrame with a labled, unediable text field.

main

public static void main(java.lang.String[] args)
Set up the display and perform necessary setup for remote execution.