class NGSession
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private boolean |
done
True if the server has been shutdown and this NGSession should terminate
completely
|
private static long |
instanceCounter
The instance counter shared among all NGSessions
|
private long |
instanceNumber
The instance number of this NGSession.
|
private java.lang.Object |
lock
Synchronization object
|
private static java.lang.Class[] |
mainSignature
signature of main(String[]) for reflection operations
|
private static java.lang.Class[] |
nailMainSignature
signature of nailMain(NGContext) for reflection operations
|
private java.net.Socket |
nextSocket
The next socket this NGSession has been tasked with processing (by
NGServer)
|
private NGServer |
server
The server this NGSession is working for
|
private NGSessionPool |
sessionPool
The pool this NGSession came from, and to which it will return itself
|
private static java.lang.Object |
sharedLock
A lock shared among all NGSessions
|
Constructor and Description |
---|
NGSession(NGSessionPool sessionPool,
NGServer server)
Creates a new NGSession running for the specified NGSessionPool and
NGServer.
|
Modifier and Type | Method and Description |
---|---|
private java.net.Socket |
nextSocket()
Returns the next socket to process.
|
void |
run()
The main NGSession loop.
|
void |
run(java.net.Socket socket)
Instructs this NGSession to process the specified socket, after which
this NGSession will return itself to the pool from which it came.
|
(package private) void |
shutdown()
Shuts down this NGSession gracefully
|
private void |
updateThreadName(java.lang.String detail)
Updates the current thread name (useful for debugging).
|
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
private NGServer server
private NGSessionPool sessionPool
private java.lang.Object lock
private java.net.Socket nextSocket
private boolean done
private long instanceNumber
private static java.lang.Object sharedLock
private static long instanceCounter
private static java.lang.Class[] mainSignature
private static java.lang.Class[] nailMainSignature
NGSession(NGSessionPool sessionPool, NGServer server)
sessionPool
- The NGSessionPool we're working forserver
- The NGServer we're working forvoid shutdown()
public void run(java.net.Socket socket)
socket
- the socket (connected to a client) to processprivate java.net.Socket nextSocket()
null
if the NGSession has been shut down.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
private void updateThreadName(java.lang.String detail)