- java.lang.Object
-
- org.xnio.conduits.AbstractConduit<D>
-
- org.xnio.conduits.AbstractSourceConduit<StreamSourceConduit>
-
- org.xnio.conduits.FramingMessageSourceConduit
-
- All Implemented Interfaces:
Conduit,MessageSourceConduit,SourceConduit
public final class FramingMessageSourceConduit extends AbstractSourceConduit<StreamSourceConduit> implements MessageSourceConduit
A message source conduit which implements a simple message framing protocol over a stream conduit.- Author:
- David M. Lloyd
-
-
Field Summary
-
Fields inherited from class org.xnio.conduits.AbstractConduit
next
-
-
Constructor Summary
Constructors Constructor Description FramingMessageSourceConduit(StreamSourceConduit next, Pooled<java.nio.ByteBuffer> receiveBuffer)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitReadable()Block until this channel becomes readable again.voidawaitReadable(long time, java.util.concurrent.TimeUnit timeUnit)Block until this conduit becomes readable again, or until the timeout expires.intreceive(java.nio.ByteBuffer dst)Receive a message.longreceive(java.nio.ByteBuffer[] dsts, int offs, int len)Receive a message.voidresumeReads()Indicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.voidterminateReads()Indicate that no more data will be read from this conduit.-
Methods inherited from class org.xnio.conduits.AbstractSourceConduit
getReadThread, isReadResumed, isReadShutdown, setReadReadyHandler, suspendReads, wakeupReads
-
Methods inherited from class org.xnio.conduits.AbstractConduit
getWorker
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xnio.conduits.SourceConduit
getReadThread, isReadResumed, isReadShutdown, setReadReadyHandler, suspendReads, wakeupReads
-
-
-
-
Constructor Detail
-
FramingMessageSourceConduit
public FramingMessageSourceConduit(StreamSourceConduit next, Pooled<java.nio.ByteBuffer> receiveBuffer)
Construct a new instance.- Parameters:
next- the delegate conduit to setreceiveBuffer- the transmit buffer to use
-
-
Method Detail
-
resumeReads
public void resumeReads()
Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.- Specified by:
resumeReadsin interfaceSourceConduit- Overrides:
resumeReadsin classAbstractSourceConduit<StreamSourceConduit>
-
awaitReadable
public void awaitReadable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOExceptionDescription copied from interface:SourceConduitBlock until this conduit becomes readable again, or until the timeout expires. This method may return spuriously before the conduit becomes readable or the timeout expires.- Specified by:
awaitReadablein interfaceSourceConduit- Overrides:
awaitReadablein classAbstractSourceConduit<StreamSourceConduit>- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
awaitReadable
public void awaitReadable() throws java.io.IOExceptionDescription copied from interface:SourceConduitBlock until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadablein interfaceSourceConduit- Overrides:
awaitReadablein classAbstractSourceConduit<StreamSourceConduit>- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
terminateReads
public void terminateReads() throws java.io.IOExceptionDescription copied from interface:SourceConduitIndicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.- Specified by:
terminateReadsin interfaceSourceConduit- Overrides:
terminateReadsin classAbstractSourceConduit<StreamSourceConduit>- Throws:
java.io.IOException- if there was a problem
-
receive
public int receive(java.nio.ByteBuffer dst) throws java.io.IOExceptionDescription copied from interface:MessageSourceConduitReceive a message.- Specified by:
receivein interfaceMessageSourceConduit- Returns:
- the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
- Throws:
java.io.IOException- if an I/O error occurs
-
receive
public long receive(java.nio.ByteBuffer[] dsts, int offs, int len) throws java.io.IOExceptionDescription copied from interface:MessageSourceConduitReceive a message.- Specified by:
receivein interfaceMessageSourceConduitoffs- the offset into the array of buffers of the first buffer to read intolen- the number of buffers to fill- Returns:
- the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
- Throws:
java.io.IOException- if an I/O error occurs
-
-