All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.ui.remote.SubjectUIServer

java.lang.Object
   |
   +----guinea.ui.remote.SubjectUIServer

public abstract class SubjectUIServer
extends Object
implements Runnable

Variable Index

· CONNECT_DONE
Connection was OK and is accepted.
· CONNECT_OK
Connection was OK and is accepted, server waits for more connections.
· defaultPort
The default port number to use for server socket.
· defaultUI
Default subject UI to send to client.
· serverThread
Thread that waits for connections and sends remote UI
· uiName
The remote UI's name (as a remote object for sending and receaving remote messages).

Constructor Index

· SubjectUIServer()
Construct a new subject UI server with default port and no default UI.
· SubjectUIServer(SubjectUI)
Construct a new subject UI server.
· SubjectUIServer(SubjectUI, int)
Construct a new subject UI server.

Method Index

· acceptsConnections()
· connectFailed(Socket, Exception)
Remote connection failed.
· connectGetUI(Socket, SubjectUI)
Return the subject UI that is sent to the remote client.
· connectGotUI(SubjectUI, RemotePipe, Socket)
A new remote subject UI is ready.
· getSocketPort()
Get the UI server socket's port number.
· getUI()
Get the default subject UI that is sent to the remote client requesting a subject UI.
· isServerRunning()
Is the socket server running awaiting for connections.
· run()
The subject UI server thread.
· setSocketPort(int)
Set the UI server socket's port number.
· setUI(SubjectUI)
Set the default subject UI that is sent to the remote client requesting a subject UI.
· startServer()
Start the subject UI server.
· stopServer()
Stop the subject UI server.

Variables

· CONNECT_OK
 public static final int CONNECT_OK
Connection was OK and is accepted, server waits for more connections.

· CONNECT_DONE
 public static final int CONNECT_DONE
Connection was OK and is accepted. This is the last client, no more connections are accepted, subject UI server quits.

· defaultPort
 public static final int defaultPort
The default port number to use for server socket.

· defaultUI
 protected SubjectUI defaultUI
Default subject UI to send to client.

· uiName
 protected String uiName
The remote UI's name (as a remote object for sending and receaving remote messages).

· serverThread
 protected Thread serverThread
Thread that waits for connections and sends remote UI

Constructors

· SubjectUIServer
 public SubjectUIServer()
Construct a new subject UI server with default port and no default UI. UI should be set before server is started or subclass should provided the UI somehow.

See Also:
connectGetUI, setUI
· SubjectUIServer
 public SubjectUIServer(SubjectUI ui,
                        int port)
Construct a new subject UI server.

Parameters:
ui - the default subject UI object to send to remote client.
port - the port number of the UI server's server socket. If port is zero, uses default port number.
· SubjectUIServer
 public SubjectUIServer(SubjectUI ui)
Construct a new subject UI server. The default server port number is used.

Parameters:
ui - the default subject UI object to send to remote client.

Methods

· isServerRunning
 public synchronized boolean isServerRunning()
Is the socket server running awaiting for connections.

Returns:
true if server is running.
· getSocketPort
 public int getSocketPort()
Get the UI server socket's port number.

Returns:
the port number of the server socket.
· setSocketPort
 public void setSocketPort(int port)
Set the UI server socket's port number. The port number cannot be set when the server is running.

Parameters:
port - the port number of the server socket.
· acceptsConnections
 public boolean acceptsConnections()
· setUI
 public synchronized void setUI(SubjectUI ui)
Set the default subject UI that is sent to the remote client requesting a subject UI. The UI cannot be set when server is already running.

Parameters:
ui - the default subject UI to use.
· getUI
 public SubjectUI getUI()
Get the default subject UI that is sent to the remote client requesting a subject UI.

Returns:
the default subject UI or null if UI hasn't been set yet.
· startServer
 public synchronized void startServer() throws IOException
Start the subject UI server. The server socket is created and a thread is started that listens for connections to the server socket. When a connection is made, the server sends the UI to the remote client and creates a server side copy of the UI.

Throws: IOException
an exception is thrown if creation of the server socket fails.
· stopServer
 public synchronized void stopServer()
Stop the subject UI server. Kills the server thread and closes the server socket so that No more connections are possible.

· run
 public final void run()
The subject UI server thread. It listens to the server socket and when a connection is received, it creates a remote pipe and sends the UI to the remote client. The run() method should be called only from the server thread. A call from some other thread is ignored and does nothing.

· connectFailed
 protected void connectFailed(Socket conn,
                              Exception ex)
Remote connection failed. Called when accepting a connection or creating remote pipe failed. This method can be used to deal with unexpected errors. The default implementation just writes the error message to standard error with a stack trace.

Parameters:
conn - the socket used for talking with the remote end.
ex - the exception that caused the connection to fail.
· connectGetUI
 protected SubjectUI connectGetUI(Socket client,
                                  SubjectUI defUI)
Return the subject UI that is sent to the remote client. Default implementation simply returns the default UI provided.

Parameters:
client - the socket that the remote client uses. This can be used to send a different UI based on client address.
defUI - the default UI to return.
Returns:
the subject UI for use in this connection. Returning null causes the server to ignore this connection and close its socket denying the connection.
· connectGotUI
 protected abstract int connectGotUI(SubjectUI ui,
                                     RemotePipe pipe,
                                     Socket s)
A new remote subject UI is ready. Subclasses should do something with the new UI.

Parameters:
ui - the UI object.
pipe - the remote pipe that is used to communicate with the remote end.
s - the socket the remote pipe uses.
Returns:
this method should return either CONNECT_OK or CONNECT_DONE.
See Also:
CONNECT_OK, CONNECT_DONE

All Packages  Class Hierarchy  This Package  Previous  Next  Index