|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread context.arch.comm.clients.ClientsPool
This class defines a pool of threads that can handle a communication. When a BaseObject wants to send an asynchronous message to another CTK object, it creates the RequestObject, added it to a IndependentCommunication object, which is the parameter of the BaseObject.independentUserRequest() call. This IndependentCommunication is added to a synchronized FIFO vector (SynchFIFO object) from which the ClientsPool get the request to send. Then, as soon as a IndependentCommunication is added to the SynchFIFO, the ClientsPool object removes it to give it to a thread (Client object) from the pool. When a Client object is asked to handle an IndependentCommunication, it is also removed from the pool. The Client object sends the request to the given CTK object, and get the reply and the exceptions. In order for the BaseObject to get the reply, the IndependentCommunication contains also 2 useful attributes : the DataObject reply and the Vector exceptions. Then the Client object adds the reply to the same object it gets as well as the exception it could have caught. After updating the IndependentCommunication object, the Client calls the BaseObject handleIndependentReply method with the parameter an object containing the same IndependentCommunication object. At the end of the communication, the IndependentCommunication object contains the original request, the reply (if any) and the exceptions that occured (if any); and is sent back to the BaseObject, that does nothing by default. If a widget or server or interpreter wants to handle the reply, it overrides the BaseObject handleIndependentReply method, and may check the reply for each request it has sent. In order to group a bunch of requests (for example, a widget sends many PINGs to its subscribers) we define a IndependentCommunications object to help handling the replies. Before sending the requests, the widget creates an IndependentCommunications object in which all IndependentCommunication objects will be added by the Client thread at the end of the communication. The IndependentCommunications object is specified while calling the BaseObject independentUserRequest. If it is null, the Client thread will create a new one, add the IndependentCommunication object in it, and send it to the BaseObject handleIndependentReply method.
Client
,
SynchFIFO
Field Summary | |
static int |
clientsNumber
The number of authorized clients |
CommunicationsObject |
comm
The Communications object |
static boolean |
DEBUG
Debug flag |
static int |
DEFAULT_CLIENTS_NUMBER
The default number of clients |
protected SynchFIFO |
fifo
This FIFO object contains the IndependentCommunication object that contain the RequestObject to send |
protected static SynchFIFO |
threads
The synchronized vector of threads |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ClientsPool()
Creates a new empty ClientsPool. |
|
ClientsPool(CommunicationsObject commObject)
Creates a ClientsPool with the default number of threads in the pool of threads. |
|
ClientsPool(int numberOfClients,
CommunicationsObject commObject)
Creates a generic ClientsPool. |
Method Summary | |
void |
addRequest(IndependentCommunication request)
This method is called to add an IndependentCommunication object containing the RequestObject to send, to the fifo object. |
void |
run()
The run method called to start the thread. |
void |
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 |
public static boolean DEBUG
protected static SynchFIFO threads
public static int clientsNumber
public static int DEFAULT_CLIENTS_NUMBER
public CommunicationsObject comm
protected SynchFIFO fifo
Constructor Detail |
public ClientsPool(int numberOfClients, CommunicationsObject commObject)
numberOfClients
- The number of available clients in the poolpublic ClientsPool(CommunicationsObject commObject)
public ClientsPool()
Method Detail |
public void run()
SynchFIFO
,
Client
public void addRequest(IndependentCommunication request)
request
- The IndependentCommunication object containing the RequestObjectSynchFIFO
public void stopAllIdleClients()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |