|
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.SessionAcceptor
A org.topoweb.util.concurrent.SingleRun
that accepts
sockets and pushes them onto an event queue. This class should be
run
in a single thread and then only once.
Field Summary | |
protected static java.util.logging.Logger |
LOGGER
|
Constructor Summary | |
SessionAcceptor(java.net.InetSocketAddress address,
SessionPool sessionPool,
org.topoweb.util.concurrent.Puttable sessionQueue)
Creates a new instance with the given parameters. |
Method Summary | |
protected void |
clean()
Frees all the network resources of this instance. |
protected boolean |
enqueue(Session session)
Enqueue's the given session in the queue. |
void |
init()
Initializes the instance. |
boolean |
isAlive()
|
void |
join(int timeout)
|
void |
run()
Runs the acceptor 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 SessionAcceptor(java.net.InetSocketAddress address, SessionPool sessionPool, org.topoweb.util.concurrent.Puttable sessionQueue) throws java.lang.IllegalArgumentException
address
- the address specifying the host and port of
the server this instance representssessionPool
- a pool/factory for creating Session
instances from accepted socketssessionQueue
- a queue used to schedule the processing of
Session
instancesMethod Detail |
public void init() throws java.lang.IllegalStateException, java.io.IOException
ACCEPT_OP
s.
Overriding subclasses must invoke super.init()
.
java.lang.IllegalStateException
- if this method has already been invoked
java.io.IOException
- if an I/O error occurspublic void run() throws java.lang.IllegalStateException
Session
instances from
them using the SessionPool
instance passed in
at instantation. These Session
instances are then
pushed on to the event queue (the Puttable sessionQueue
parameter passed in at instantation) for processing by another stage.
The acceptor loop can be signaled to stop through the stop
method.
run
in interface org.topoweb.util.concurrent.SingleRun
java.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.SingleRun
java.lang.IllegalStateException
public 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.SingleRun
java.lang.InterruptedException
protected boolean enqueue(Session session)
session
in the 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.protected void clean()
|
TopoWeb Commons API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |