Package org.simpleframework.transport
Class ServerCleaner
- java.lang.Object
-
- org.simpleframework.common.thread.Daemon
-
- org.simpleframework.transport.ServerCleaner
-
- All Implemented Interfaces:
java.lang.Runnable
class ServerCleaner extends Daemon
TheServerCleanerobject allows for the termination and resource recovery to be done asynchronously. This ensures that should a HTTP request be used to terminate the processor that it does not block waiting for the servicing thread pool to terminate causing a deadlock.
-
-
Field Summary
Fields Modifier and Type Field Description private ConcurrentExecutorexecutorThis is the thread pool implementation used by the server.private TransportProcessorprocessorThis is the internal processor that is to be terminated.private ReactorreactorThis is the internal write reactor that is terminated.
-
Constructor Summary
Constructors Constructor Description ServerCleaner(TransportProcessor processor, ConcurrentExecutor executor, Reactor reactor)Constructor for theServerCleanerobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrun()When this method runs it will firstly stop the processor in a synchronous fashion.
-
-
-
Field Detail
-
processor
private final TransportProcessor processor
This is the internal processor that is to be terminated.
-
executor
private final ConcurrentExecutor executor
This is the thread pool implementation used by the server.
-
reactor
private final Reactor reactor
This is the internal write reactor that is terminated.
-
-
Constructor Detail
-
ServerCleaner
public ServerCleaner(TransportProcessor processor, ConcurrentExecutor executor, Reactor reactor)
Constructor for theServerCleanerobject. For an orderly termination of the processor, the processor and reactor provided to the constructor will be stopped asynchronously.- Parameters:
processor- this is the processor that is to be stoppedexecutor- this is the executor used by the serverreactor- this is the reactor that is to be closed
-
-
Method Detail
-
run
public void run()
When this method runs it will firstly stop the processor in a synchronous fashion. Once theTransportProcessorhas stopped it will stop theReactorensuring that all threads will be released.It is important to note that stopping the processor before stopping the reactor is required. This ensures that if there are any threads executing within the processor that require the reactor threads, they can complete without a problem.
-
-