context.arch.comm.clients
Class Client

java.lang.Object
  extended byjava.lang.Thread
      extended bycontext.arch.comm.clients.ClientsPool
          extended bycontext.arch.comm.clients.Client
All Implemented Interfaces:
java.lang.Runnable

public class Client
extends ClientsPool

This class allows to get an IndependentCommunication object, to send the contained RequestObject via the BaseObject, to get the reply or the exceptions, and to send back all that information to the caller BaseObject thru the BaseObject handleIndependentReply method.

Author:
Agathe
See Also:
ClientsPool, BaseObject

Field Summary
static boolean DEBUG
          Debug flag
 java.lang.String id
          The id of the client
protected  IndependentCommunication indComm
          The IndependentCommunication object containing the RequestObject to send
 
Fields inherited from class context.arch.comm.clients.ClientsPool
clientsNumber, comm, DEFAULT_CLIENTS_NUMBER, fifo, threads
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Client(CommunicationsObject commObject, java.lang.String name)
          Creates new Client.
 
Method Summary
 void debugprintln(java.lang.Object s)
          Print a message if the DEBUG mode is active
 boolean getRequest()
          This method tests if the IndependentCommunication is set or not
 void releaseRequest()
          This method allows to clear the IndependentCommunication of the Client
 void run()
          The method called to start the Client.
 void sendReply()
          This method allows to send to the BaseObject the result of the communication, if the client requires the response.
 void setRequest(IndependentCommunication independentCommunication)
          This method sets the IndependentCommunication of the Client and notifies it.
protected  void waitForRequest()
          This method allows to wait for the next IndependentCommunication object
 
Methods inherited from class context.arch.comm.clients.ClientsPool
addRequest, stopAllIdleClients
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Debug flag


id

public java.lang.String id
The id of the client


indComm

protected IndependentCommunication indComm
The IndependentCommunication object containing the RequestObject to send

Constructor Detail

Client

public Client(CommunicationsObject commObject,
              java.lang.String name)
Creates new Client.

Parameters:
name - The name of the client
Method Detail

run

public void run()
The method called to start the Client. It waits for the next IndependentCommunication object sent by the ClientsPool, and then sends the RequestObject. It adds the reply and the exception occured in the same IndependentCommunication object. If an IndependentCommunications object is defined in the IndependentCommunication object, it adds the last in the groups and calls the handleIndependentReply of the BaseObject. It adds itself back to the pool of thread of the ClientsPool and then it waits for the next IndependentCommunication.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class ClientsPool
See Also:
SynchFIFO, Client

waitForRequest

protected void waitForRequest()
This method allows to wait for the next IndependentCommunication object


getRequest

public boolean getRequest()
This method tests if the IndependentCommunication is set or not

Returns:
boolean True if the Client has an IndependentCommunication, false otherwise

setRequest

public void setRequest(IndependentCommunication independentCommunication)
This method sets the IndependentCommunication of the Client and notifies it.

Parameters:
independentCommunication - The IndependentCommunication object

sendReply

public void sendReply()
This method allows to send to the BaseObject the result of the communication, if the client requires the response. The result is put in the original IndependentCommunication updated with the reply and the exceptions of the communication.


releaseRequest

public void releaseRequest()
This method allows to clear the IndependentCommunication of the Client


debugprintln

public void debugprintln(java.lang.Object s)
Print a message if the DEBUG mode is active

Parameters:
s - Any object, even null