public class BytesMethodReader extends net.openhft.chronicle.core.io.SimpleCloseable implements MethodReader
The class also maintains an internal list of method encoders, which are stored in the order that they were added. This allows the BytesMethodReader to efficiently look up the appropriate method encoder based on a messageId.
The BytesMethodReader is not thread-safe.
HISTORY, MESSAGE_HISTORY_METHOD_ID
Constructor and Description |
---|
BytesMethodReader(BytesIn<?> in,
BytesParselet defaultParselet,
MethodEncoderLookup methodEncoderLookup,
Object[] objects)
Constructor for the BytesMethodReader class.
|
Modifier and Type | Method and Description |
---|---|
MethodReader |
closeIn(boolean closeIn)
Sets whether the underlying input should be closed when the MethodReader is closed.
|
MethodReaderInterceptorReturns |
methodReaderInterceptorReturns()
Throws an UnsupportedOperationException when called.
|
boolean |
readOne()
Attempts to read a single message from the BytesIn object.
|
close, isClosed, performClose
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, closeQuietly, closeQuietly
public BytesMethodReader(BytesIn<?> in, BytesParselet defaultParselet, MethodEncoderLookup methodEncoderLookup, Object[] objects)
Initializes a new instance of the BytesMethodReader with a BytesIn object, a default BytesParselet, and a methodEncoderLookup function. The constructor also accepts an array of objects which represent the possible targets for the method calls that this reader will dispatch.
in
- the BytesIn object from which serialized method calls are read.defaultParselet
- the default BytesParselet used when reading method calls.methodEncoderLookup
- the lookup function used to find a method's encoder.objects
- the array of objects that can be targets of method calls.public MethodReaderInterceptorReturns methodReaderInterceptorReturns()
This method is required to fulfill the MethodReader interface, but it is not supported in the BytesMethodReader class.
methodReaderInterceptorReturns
in interface MethodReader
UnsupportedOperationException
- alwayspublic boolean readOne() throws net.openhft.chronicle.core.util.InvocationTargetRuntimeException, IllegalStateException, BufferUnderflowException
If a suitable method encoder is found, it is used to decode the message and the corresponding method is invoked. Otherwise, the default parselet is used.
If the reader is closed or if there are no more messages to read, the method returns false
.
readOne
in interface MethodReader
true
if a message was successfully read, false
if no more messages are availablenet.openhft.chronicle.core.util.InvocationTargetRuntimeException
- If an exception is thrown by the target methodBufferUnderflowException
- If there is not enough data available in the buffer to read the next messagenet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
public MethodReader closeIn(boolean closeIn)
Note: This method currently does not alter the close behavior of the BytesMethodReader. It returns the MethodReader itself for method chaining.
closeIn
in interface MethodReader
closeIn
- true
to close the input when this reader is closed, false
otherwiseCopyright © 2023. All rights reserved.