Package org.simpleframework.transport
Class TransportDispatcher
- java.lang.Object
-
- org.simpleframework.transport.TransportDispatcher
-
- All Implemented Interfaces:
java.lang.Runnable
,Operation
class TransportDispatcher extends java.lang.Object implements Operation
TheTransportDispatcher
operation is used transfer a transport to the processor so it can be processed. This is used so that when a transport is given to the processor it can be dispatched in another thread to the processor. This is needed so that the connection thread is occupied only briefly.
-
-
Field Summary
Fields Modifier and Type Field Description private TransportProcessor
processor
This is the processor used to transfer the transport to.private Transport
transport
This is the transport to be passed to the processor.
-
Constructor Summary
Constructors Constructor Description TransportDispatcher(TransportProcessor processor, Transport transport)
Constructor for theTransportDispatcher
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
This is used to cancel the operation if it has timed out.java.nio.channels.SocketChannel
getChannel()
This is theSelectableChannel
which is used to determine if the operation should be executed.Trace
getTrace()
This is used to acquire the trace object that is associated with the operation.void
run()
This is used to transfer the transport to the processor.
-
-
-
Field Detail
-
processor
private final TransportProcessor processor
This is the processor used to transfer the transport to.
-
transport
private final Transport transport
This is the transport to be passed to the processor.
-
-
Constructor Detail
-
TransportDispatcher
public TransportDispatcher(TransportProcessor processor, Transport transport)
Constructor for theTransportDispatcher
object. This is used to transfer a transport to a processor. Transferring the transport using an operation ensures that the thread that is used to process the transport is not occupied for long.- Parameters:
transport
- this is the transport this exchange usesprocessor
- this is the negotiation to dispatch to
-
-
Method Detail
-
getChannel
public java.nio.channels.SocketChannel getChannel()
This is theSelectableChannel
which is used to determine if the operation should be executed. If the channel is ready for a given I/O event it can be run. For instance if the operation is used to perform some form of read operation it can be executed when ready to read data from the channel.- Specified by:
getChannel
in interfaceOperation
- Returns:
- this returns the channel used to govern execution
-
getTrace
public Trace getTrace()
This is used to acquire the trace object that is associated with the operation. A trace object is used to collection details on what operations are being performed. For instance it may contain information relating to I/O events or errors.
-
run
public void run()
This is used to transfer the transport to the processor. This will typically be executed asynchronously so that it does not delay the thread that passes theTransport
to the transport processor, ensuring quicker processing.- Specified by:
run
in interfacejava.lang.Runnable
-
cancel
public void cancel()
This is used to cancel the operation if it has timed out. This is typically invoked when it has been waiting in a selector for an extended duration of time without any active operations on it. In such a case the reactor must purge the operation to free the memory and open channels associated with the operation.
-
-