|
TopoWeb Commons API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.topoweb.net.server.SessionReader
An org.topoweb.util.concurrent.SingleRun that reads from
sockets. Receives new Sessions from a queue and registers
them with an internally managed selector that detects the readiness of
sockets for read operations. Reads from sockets until the completion of
an interpretable request is detected, and then enqueue's the socket's
associated Session for processing by some other agent.
run in a single thread and then only once.
| Field Summary | |
protected static java.util.logging.Logger |
LOGGER
The logger used to log messages. |
| Constructor Summary | |
SessionReader(org.topoweb.util.concurrent.Takable readPendingQueue,
org.topoweb.util.concurrent.Puttable readCompletedQueue,
RequestBoundaryDetector requestDetector,
SessionPool sessionPool)
Creates a new instance with the given parameters. |
|
| Method Summary | |
protected boolean |
enqueue(Session session)
Enqueue's the given session in the read-completed
queue. |
void |
init()
Initializes the instance. |
boolean |
isAlive()
|
void |
join(int timeout)
|
void |
run()
Runs the session reader loop. |
void |
stop()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final java.util.logging.Logger LOGGER
| Constructor Detail |
public SessionReader(org.topoweb.util.concurrent.Takable readPendingQueue,
org.topoweb.util.concurrent.Puttable readCompletedQueue,
RequestBoundaryDetector requestDetector,
SessionPool sessionPool)
throws java.lang.IllegalArgumentException
readPendingQueue - the queue from which
Sessions arrivereadCompletedQueue - the queue on which Sessions
are sent once a request has been completely
readrequestDetector - the request boundary detector used to tell
whether enough bytes have been read to form
an interpretable requestsessionPool - the pool to which cancelled Session
instances are returned
java.lang.IllegalArgumentException - if any of the arguments is null| Method Detail |
public void init()
throws java.lang.IllegalStateException,
java.io.IOException
java.lang.IllegalStateException - if this method has already been invoked
java.io.IOException - if an I/O error occurs
public void run()
throws java.lang.IllegalStateException
run in interface org.topoweb.util.concurrent.SingleRunjava.lang.IllegalStateException - if the instance was not first
initialized; if invoked
more than onceinit(),
stop()
public void stop()
throws java.lang.IllegalStateException
stop in interface org.topoweb.util.concurrent.SingleRunjava.lang.IllegalStateExceptionpublic boolean isAlive()
isAlive in interface org.topoweb.util.concurrent.SingleRun
public void join(int timeout)
throws java.lang.InterruptedException
join in interface org.topoweb.util.concurrent.SingleRunjava.lang.InterruptedExceptionprotected boolean enqueue(Session session)
session in the read-completed
queue. The basic implementation waits roughly 1 second for the queue
operation to succeed.
session - the session to be enqueued
true, if successfully enqueued;
false, o.w.
|
TopoWeb Commons API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||