|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.xcap.client.ThreadedRequestHandler
public class ThreadedRequestHandler
Field Summary | |
---|---|
static java.lang.String |
CLASSNAME
Classname |
protected java.lang.Object |
lock
Lock for the request counter int |
static java.util.logging.Logger |
LOGGER
Logger for this class |
protected static int |
maxSize
|
protected static int |
minSize
ThreadPool size |
protected int |
requestCounter
Counter for the number of requests received |
protected static int |
responseListSize
Initial size of the responce vector. |
protected java.util.Vector<XcapClientResponse> |
responses
Container for responses received from worker threads |
protected static WorkerThreadPool |
threadPool
Worker Threads |
Constructor Summary | |
---|---|
ThreadedRequestHandler()
|
|
ThreadedRequestHandler(int responseListSize)
Creates an object that uses the static threadPool to service RequestTasks via the executeRequest(XcapClientRequest request) method |
Method Summary | |
---|---|
static void |
destroyThreadPool()
Clean up the thread pool resources. |
void |
executeRequest(XcapClientRequest request)
Convenience method to execute this#executeRequest(XcapClientRequest, boolean)
with the parameter set to true. |
void |
executeRequest(XcapClientRequest request,
boolean useThreadpool)
Execute a XcapClientRequest attempting to obtain a
worker thread rather than using the current thread as directed
by the boolean attemptSpinoff paramater. |
java.util.Vector |
getResponses()
Get the Vector containing all of the responses from requests
sent through this instance. |
void |
notifyListener(XcapClientResponse response)
Add a XcapClientResponse to the response list. |
static void |
setThreadPoolSize(int maxSize)
Set the maximum number of worker threads allowed to be created by the threadpool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CLASSNAME
public static final java.util.logging.Logger LOGGER
protected static int minSize
protected static int maxSize
protected static WorkerThreadPool threadPool
protected static int responseListSize
protected java.util.Vector<XcapClientResponse> responses
protected int requestCounter
protected java.lang.Object lock
Constructor Detail |
---|
public ThreadedRequestHandler()
public ThreadedRequestHandler(int responseListSize)
responseListSize
- initial size of response VectorMethod Detail |
---|
public void executeRequest(XcapClientRequest request)
this#executeRequest(XcapClientRequest, boolean)
with the parameter set to true. This will handle a request
by attempting to obtain a worker thread from the threadpool.
If no worker thread is available because the threadpool is
depleated, the calling thread is used to handle the request.
This avoids the possibility of starvation.
request
- the request to process#executeRequest(XcapClientRequest, boolean)}
public void executeRequest(XcapClientRequest request, boolean useThreadpool)
XcapClientRequest
attempting to obtain a
worker thread rather than using the current thread as directed
by the boolean attemptSpinoff paramater. If no worker thread is
available because the threadpool is depleated, the calling
thread is used to handle the request. This avoids the possibility
of starvation. Callers wishing to use their current thread to
process the request should pass a false boolean
for the second paramater to force the use of the current thread
for request handling.
request
- the request to processuseThreadpool
- boolean indicating if an attempt should
be made to use a thread from the
thread pool to handle requestXcapClientRequest
public void notifyListener(XcapClientResponse response)
XcapClientResponse
to the response list.
This method is automatically called by a RequestTask
when
a response is recieved from sending a request.
response
- the response to processXcapClientResponse
public java.util.Vector getResponses()
Vector
containing all of the responses from requests
sent through this instance. This method blocks until all responses
are received.
public static void setThreadPoolSize(int maxSize)
public static void destroyThreadPool()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |