Package org.jtrim2.concurrent.query.io
Class DeserializerChannelProcessor
java.lang.Object
org.jtrim2.concurrent.query.io.DeserializerChannelProcessor
- All Implemented Interfaces:
ChannelProcessor<Object,
ReadableByteChannel>
public final class DeserializerChannelProcessor
extends Object
implements ChannelProcessor<Object,ReadableByteChannel>
Defines a
ChannelProcessor
which reads and deserializes the first
object from the specified channel. This ChannelProcessor
requires a
ReadableByteChannel
to read the bytes from. The object read from the
channel will be forwarded to the specified AsyncDataListener
.
Thread safety
As required by theChannelProcessor
, this class is safe to be
accessed by multiple threads concurrently.
Synchronization transparency
Methods of this class are not synchronization transparent.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jtrim2.concurrent.query.io.ChannelProcessor
ChannelProcessor.StateListener
-
Constructor Summary
ConstructorDescriptionCreates a newDeserializerChannelProcessor
which is ready to read the objects from the provided channel. -
Method Summary
Modifier and TypeMethodDescriptionvoid
processChannel
(ReadableByteChannel channel, AsyncDataListener<Object> listener, ChannelProcessor.StateListener stateListener) Processes the content of specified open channel and forwards the processed content to the specifiedAsyncDataListener
.
-
Constructor Details
-
DeserializerChannelProcessor
public DeserializerChannelProcessor()Creates a newDeserializerChannelProcessor
which is ready to read the objects from the provided channel.
-
-
Method Details
-
processChannel
public void processChannel(ReadableByteChannel channel, AsyncDataListener<Object> listener, ChannelProcessor.StateListener stateListener) throws IOException Processes the content of specified open channel and forwards the processed content to the specifiedAsyncDataListener
. This method may or may not call theonDoneReceive
method of the specified listener but if it does, it must honor the contract of theAsyncDataListener
and stop forwarding anymore data.Implementation note: This method may read more bytes from the specified channel than necessary to read the first object.
- Specified by:
processChannel
in interfaceChannelProcessor<Object,
ReadableByteChannel> - Parameters:
channel
- the channel whose content is to be processed and be forwarded to the specified listener. This channel may only be accessed in this method call and does not need to be closed in this method call. This argument cannot benull
.listener
- the listener to which processed data is to be forwarded. The data maybe forwarded only during this method call. TheonDoneReceive
method of this listener does not need to be called by this method but otherwise, this method must honor the contract of the listener. This argument cannot benull
.stateListener
- theStateListener
through which this method call may show its current progress of processing the channel. This argument cannot benull
.- Throws:
IOException
- thrown if there was some error, while processing the channel. Throwing this exception, of course, means the termination of the data providing.
-