|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.net.server.ConcurrentServerRunner<T>
public abstract class ConcurrentServerRunner<T extends Client>
A concurrent ServerRunner.
An instance of this object is created with a ServerListener and
an Executor. On invocation of the #start() method, it
passes itself to the given Executor and returns immediately. On
invocation of its run() method by the Executor it begins
accepting client connections via its ServerListener. As each
new Client is accepted, the client is configured with the
runner's LoggingContext and is then passed to the Executor for concurrent execution of the client's service loop.
On invocation of the stop() method, the runner closes the listener
and each of the connected clients (by invoking Client.close()
effectively interrupting any blocked I/O calls and causing these concurrent
subtasks to exit gracefully). This ensures that before the stop()
method returns (1) all I/O resources have been released and (2) all
of the threads of the Executor are idle.
| Field Summary |
|---|
| Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase |
|---|
context |
| Constructor Summary | |
|---|---|
ConcurrentServerRunner(ServerListener<T> listener,
Executor executor)
Constructs a new server runner. |
|
| Method Summary | |
|---|---|
void |
accept(ClientVisitor<T> visitor)
Presents each connected client to the given visitor. |
protected abstract boolean |
configureClient(T client)
Configures a connected client. |
boolean |
isRunning()
Gets a flag indicating whether the server is currently running. |
void |
run()
|
protected void |
setRunning(boolean running)
|
void |
stop()
Stops execution of the runner. |
| Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase |
|---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface ch.qos.logback.core.spi.ContextAware |
|---|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext |
| Constructor Detail |
|---|
public ConcurrentServerRunner(ServerListener<T> listener,
Executor executor)
listener - the listener from which the server will accept new
clientsexecutor - a executor that will facilitate execution of the
listening and client-handling tasks; while any Executor
is allowed here, outside of unit testing the only reasonable choice
is a bounded thread pool of some kind.| Method Detail |
|---|
public boolean isRunning()
isRunning in interface ServerRunner<T extends Client>protected void setRunning(boolean running)
public void stop()
throws IOException
This method must cause all I/O and thread resources associated with the runner to be released. If the receiver has not been started, this method must have no effect.
stop in interface ServerRunner<T extends Client>IOExceptionpublic void accept(ClientVisitor<T> visitor)
accept in interface ServerRunner<T extends Client>visitor - the subject visitorpublic void run()
run in interface Runnableprotected abstract boolean configureClient(T client)
A subclass implements this method to perform any necessary configuration
of the client object before its Runnable.run() method is invoked.
client - the subject client
true if configuration was successful; if the return
value is false the client connection will be dropped
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||