public class RequestServerHandler
extends atg.core.util.DictionaryThread
This is the base class for objects that handle individual requests. Subclasses should override handleRequest().
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected RequestServer |
mServer
The RequestServer that this belongs to
|
protected boolean |
mShuttingDown
Flag if we are in the process of shutting down
|
protected java.net.Socket |
mSocket
The Socket this should use, if a one-shot handler
|
protected boolean |
mWaitingForClient
Flag set to true if we are in the middle of waiting for the client.
|
protected boolean |
mZombie
Flag showing if this server has been killed
|
Constructor and Description |
---|
RequestServerHandler(java.lang.ThreadGroup pGroup,
java.lang.String pThreadName,
RequestServer pServer,
java.net.Socket pSocket)
Constructs a new RequestServerHandler that belongs to the
specified RequestServer.
|
Modifier and Type | Method and Description |
---|---|
long |
getCurrentRequestStartTime()
Returns the time at which the request began processing
|
boolean |
getHandlingRequest()
Returns the flag indicating if this is currently handling a
request
|
long |
getRequestLastActivityTime()
Returns the last time activity occurred on this request
|
RequestServer |
getRequestServer()
Returns the RequestServer this handler was created from
|
boolean |
getShuttingDown()
Returns the flag indicating if this is currently
shutting down
|
boolean |
getWaitingForClient()
Returns true if we are in the middle of writing data to the client.
|
boolean |
getZombie()
Returns the flag indicating if this thread has been killed.
|
protected void |
handlerCleanup()
Called before this handler exits.
|
protected void |
handleRequest(java.net.Socket pSocket)
This is the method that actually handles the request from the
specified socket.
|
void |
killHandler()
Kills this thread.
|
static void |
logErrorForException(java.lang.Throwable t,
ApplicationLogging pLogger,
boolean bSkipTopException)
Use log error to log the exception, following the cain of
container exceptions.
|
void |
run()
Runs this handler.
|
void |
setCurrentRequestStartTime(long pCurrentRequestStartTime)
Sets the time at which the request began processing
|
void |
setHandlingRequest(boolean pHandlingRequest)
Sets the flag indicating if this is currently handling a request
|
void |
setRequestLastActivityTime(long pRequestLastActivityTime)
Sets the last time activity occurred on this request
|
void |
setShuttingDown(boolean pShuttingDown)
Sets the flag indicating if this is currently
shutting down
|
void |
setWaitingForClient(boolean pWaitingForClient)
Sets the flag indicating if this is currently
waiting for the client.
|
void |
setZombie(boolean pZombie)
Sets the flag indicating if this thread has been killed.
|
getDictionary, getObject, getThreadDictionary
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static java.lang.String CLASS_VERSION
protected RequestServer mServer
protected java.net.Socket mSocket
protected boolean mShuttingDown
protected boolean mWaitingForClient
protected boolean mZombie
public RequestServerHandler(java.lang.ThreadGroup pGroup, java.lang.String pThreadName, RequestServer pServer, java.net.Socket pSocket)
pGroup
- the ThreadGroup to which this will belongpThreadName
- the name that should be given to this ThreadpServer
- the RequestServer handling thispSocket
- the socket this should use to handle its request.
If non-null, then this handler's run method should handle a
single request from the socket and exist. If null, then the
handler's run method should repeatedly obtain sockets and handle
requests from the server by calling "acceptConnection".public RequestServer getRequestServer()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void handleRequest(java.net.Socket pSocket)
Note for subclasses overriding handleRequest(). You must check the mShuttingDown field if you enter into an inner loop. Otherwize the RequestServer may be forced during shutdown to kill your thread even while you are handling a request.
public void killHandler()
public boolean getHandlingRequest()
public void setHandlingRequest(boolean pHandlingRequest)
public boolean getShuttingDown()
public void setShuttingDown(boolean pShuttingDown)
public boolean getZombie()
public void setZombie(boolean pZombie)
public boolean getWaitingForClient()
public void setWaitingForClient(boolean pWaitingForClient)
public long getCurrentRequestStartTime()
public void setCurrentRequestStartTime(long pCurrentRequestStartTime)
public long getRequestLastActivityTime()
public void setRequestLastActivityTime(long pRequestLastActivityTime)
protected void handlerCleanup()
public static void logErrorForException(java.lang.Throwable t, ApplicationLogging pLogger, boolean bSkipTopException)