Methods Summary |
---|
synchronized void | assign(java.net.Socket socket)Process an incoming TCP/IP connection on the specified socket. Any
exception that occurs during processing must be logged and swallowed.
NOTE: This method is called from our Connector's thread. We
must assign it to our own thread so that multiple simultaneous
requests can be handled.
// Wait for the Processor to get the previous Socket
while (available) {
try {
wait();
} catch (InterruptedException e) {
}
}
// Store the newly available Socket and notify our thread
this.socket = socket;
available = true;
notifyAll();
|
private synchronized java.net.Socket | await()Await a newly assigned Socket from our Connector, or null
if we are supposed to shut down.
// Wait for the Connector to provide a new Socket
while (!available) {
try {
wait();
} catch (InterruptedException e) {
}
}
// Notify the Connector that we have received this Socket
Socket socket = this.socket;
available = false;
notifyAll();
return (socket);
|
public void | run()The background thread that listens for incoming TCP/IP connections and
hands them off to an appropriate processor.
// Process requests until we receive a shutdown signal
while (!stopped) {
// Wait for the next socket to be assigned
Socket socket = await();
if (socket == null)
continue;
// Process the request from this socket
endpoint.processSocket(socket, con, threadData);
// Finish up this request
endpoint.recycleWorkerThread(this);
}
// Tell threadStop() we have shut ourselves down successfully
synchronized (threadSync) {
threadSync.notifyAll();
}
|
public void | start()Start the background processing thread.
threadData = endpoint.getConnectionHandler().init();
thread = new ThreadWithAttributes(null, this);
thread.setName(threadName);
thread.setDaemon(true);
thread.start();
|
public void | stop()Stop the background processing thread.
stopped = true;
assign(null);
thread = null;
threadData = null;
|