|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectclient.Client
public class Client
Class Client is a simple illustration of a client that communicates with a remote server using RMI. The client provides server-setup and computation methods, detailed descriptions of which are given in the method documentation.
The main method of the client accepts two command-line arguments. The first argument is the name of the host on which the server is running. The host name may be suffixed with a colon-delimited port number. If the port number is not present, the rmiregistry on the remote host is assumed to be running on the well-known port 1099. So, e.g., a legal hostname could be "waldorf.csc.calpoly.edu" or "waldorf.csc.calpoly.edu:1098", the latter selecting alternate registry port 1098.
The second command-line argument is an optional flag indicating if the client's GUI should be displayed when it runs. If the argument is missing, the default behavior is to display the GUI. If the second argument is "-nd", then no GUI display is shown. Using the "-nd" argument is useful when the client is run in a context where there is no support for a Java GUI display, for example, running the client on a UNIX machine like waldorf when logged into waldorf via telnet from a Windows PC.
See the Server class for a description of the server that this client uses.
Field Summary | |
---|---|
protected static boolean |
displayOn
True if the display is on, i.e., the 2nd command-line arg != "-nd" |
protected static ServerInterface |
server
The remote server class; note the use of the interface type in the declaration, which means that the server implementation need not be (and typically is not) on the client machine. |
protected static javax.swing.JTextField |
textField
The text field that displays the result computed by the server; the result is printed to stdout instead of this text field if the GUI display is not active |
Constructor Summary | |
---|---|
Client()
|
Method Summary | |
---|---|
protected static void |
establishCommunication(java.lang.String hostname)
Establish communication with the server running on the given hostname. |
static void |
main(java.lang.String[] args)
Get the hostname from command-line argument, exiting if there is none. |
protected static void |
performComputation()
Call the following methods on the remote server: receiveClientInput compute getServerOutput Display the resulting server output in the display window, or write the output to stdout if the display is not on. |
protected static void |
setupDisplay(java.lang.String hostname)
Set up the display as a JFrame with a labeled text field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static ServerInterface server
protected static javax.swing.JTextField textField
protected static boolean displayOn
Constructor Detail |
---|
public Client()
Method Detail |
---|
protected static void establishCommunication(java.lang.String hostname)
protected static void setupDisplay(java.lang.String hostname)
protected static void performComputation()
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |