arlut.csd.ganymede.client
Class ClientBase

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--arlut.csd.ganymede.client.ClientBase
All Implemented Interfaces:
Client, java.rmi.Remote, java.io.Serializable

public class ClientBase
extends java.rmi.server.UnicastRemoteObject
implements Client

The core of a client. Provides all the logic necessary to establish a connection to the server and get logged in. By using this class, the server will only need an RMI stub for this class, regardless of what client is written.

See Also:
Serialized Form

Field Summary
private  boolean connected
           
private static boolean debug
           
private  java.util.Vector listeners
           
private  java.lang.String loginRefuseMessage
           
private  java.lang.String password
           
private  arlut.csd.ganymede.Server server
          RMI reference to a Ganymede server
private  arlut.csd.ganymede.Session session
          RMI reference to a client session on a Ganymede server
private  java.lang.String username
           
private  arlut.csd.ganymede.XMLSession xSession
          RMI reference to a client XMLSession on a Ganymede server
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ClientBase(java.lang.String serverURL, arlut.csd.ganymede.client.ClientListener listener)
          This constructor takes a URL for the Ganymede server to connect to, a reference to an object implementing the ClientListener interface to report problems.
 
Method Summary
 void addClientListener(arlut.csd.ganymede.client.ClientListener l)
          Register a client listener.
 void disconnect()
          Calls the logout() method on the Session object.
 void forceDisconnect(java.lang.String reason)
          Allows the server to force us off when it goes down.
 java.lang.String getName()
          Allows the server to retrieve the username.
 java.lang.String getPassword()
          Allows the server to retrieve the password.
 arlut.csd.ganymede.Session getSession()
          This method can be used to retrieve a handle to the client's login session.
 arlut.csd.ganymede.XMLSession getXSession()
          This method can be used to retrieve a handle to the client's login session.
 boolean isConnected()
          This method returns true if the client holds a valid reference to the server.
 boolean isLoggedIn()
          This method returns true if the client has already logged in.
 arlut.csd.ganymede.Session login(java.lang.String username, java.lang.String password)
          This method is used by a client to actually get logged into the server.
 void removeClientListener(arlut.csd.ganymede.client.ClientListener l)
          Remove a client listener.
private  void sendErrorMessage(java.lang.String message)
          Private method to inform clientListeners if we get an error from the server after construction..
 void sendMessage(int messageType, java.lang.String status)
          Allows the server to send an asynchronous message to the client..
 arlut.csd.ganymede.XMLSession xmlLogin(java.lang.String username, java.lang.String password)
          This method is used by a client to actually get logged into the server.
 
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

debug

private static final boolean debug
See Also:
Constant Field Values

server

private arlut.csd.ganymede.Server server
RMI reference to a Ganymede server


session

private arlut.csd.ganymede.Session session
RMI reference to a client session on a Ganymede server


xSession

private arlut.csd.ganymede.XMLSession xSession
RMI reference to a client XMLSession on a Ganymede server


username

private java.lang.String username

password

private java.lang.String password

connected

private boolean connected

listeners

private java.util.Vector listeners

loginRefuseMessage

private java.lang.String loginRefuseMessage
Constructor Detail

ClientBase

public ClientBase(java.lang.String serverURL,
                  arlut.csd.ganymede.client.ClientListener listener)
           throws java.rmi.RemoteException

This constructor takes a URL for the Ganymede server to connect to, a reference to an object implementing the ClientListener interface to report problems. The constructor will establish an initial connection to the server and prepare itself for subsequent login before returning.

Parameters:
serverURL - An rmi:// URL for a Ganymede server.
listener - A ClientListener to report problems and disconnection to.
Method Detail

login

public arlut.csd.ganymede.Session login(java.lang.String username,
                                        java.lang.String password)
                                 throws java.rmi.RemoteException

This method is used by a client to actually get logged into the server. The Session handle returned is then used to do all server operations appropriate for a normal client. Calling the Session logout() method will end the client's connection to the server.

Returns:
null if login failed, else a valid server Session reference
java.rmi.RemoteException
See Also:
Session

xmlLogin

public arlut.csd.ganymede.XMLSession xmlLogin(java.lang.String username,
                                              java.lang.String password)
                                       throws java.rmi.RemoteException

This method is used by a client to actually get logged into the server. The Session handle returned is then used to do all server operations appropriate for a normal client. Calling the Session logout() method will end the client's connection to the server.

Returns:
null if login failed, else a valid server Session reference
java.rmi.RemoteException
See Also:
Session

isLoggedIn

public boolean isLoggedIn()
This method returns true if the client has already logged in.


getSession

public arlut.csd.ganymede.Session getSession()

This method can be used to retrieve a handle to the client's login session. This simply returns the same handle that login() returned, in case the client forgets it or something.


getXSession

public arlut.csd.ganymede.XMLSession getXSession()

This method can be used to retrieve a handle to the client's login session. This simply returns the same handle that login() returned, in case the client forgets it or something.


isConnected

public boolean isConnected()

This method returns true if the client holds a valid reference to the server. This will always return true unless the server has forced a disconnect.


addClientListener

public void addClientListener(arlut.csd.ganymede.client.ClientListener l)

Register a client listener. A client listener is an object that is to be notified if we get an asynchronous callback from the Ganymede server, such as a forced log-off, or if we need to report an error during login.


removeClientListener

public void removeClientListener(arlut.csd.ganymede.client.ClientListener l)

Remove a client listener.


disconnect

public void disconnect()
                throws java.rmi.RemoteException

Calls the logout() method on the Session object. This could be done by the client using the Session reference returned by the login() method, but using this method allows us to reflect login status internally.

java.rmi.RemoteException

getName

public java.lang.String getName()

Allows the server to retrieve the username.

Specified by:
getName in interface Client
See Also:
Client

getPassword

public java.lang.String getPassword()

Allows the server to retrieve the password.

Specified by:
getPassword in interface Client
See Also:
Client

forceDisconnect

public void forceDisconnect(java.lang.String reason)

Allows the server to force us off when it goes down.

Specified by:
forceDisconnect in interface Client
See Also:
Client

sendMessage

public void sendMessage(int messageType,
                        java.lang.String status)

Allows the server to send an asynchronous message to the client.. Used by the server to tell the client when a build is/is not being performed on the server.

Specified by:
sendMessage in interface Client
See Also:
Client

sendErrorMessage

private void sendErrorMessage(java.lang.String message)

Private method to inform clientListeners if we get an error from the server after construction..