Package org.refcodes.io
Class PrefetchBidirectionalStreamConnectionTransceiverImpl<DATA extends Serializable>
- java.lang.Object
-
- org.refcodes.component.AbstractConnectableAutomaton
-
- org.refcodes.io.AbstractReceiver<DATA>
-
- org.refcodes.io.AbstractPrefetchInputStreamReceiver<DATA>
-
- org.refcodes.io.PrefetchBidirectionalStreamConnectionTransceiverImpl<DATA>
-
- Type Parameters:
DATA
- the generic type
- All Implemented Interfaces:
Flushable
,org.refcodes.component.BidirectionalConnectionComponent<DATA,INPUT>
,org.refcodes.component.BidirectionalConnectionComponent.BidirectionalConnectionAutomaton<INPUT,OUTPUT>
,org.refcodes.component.BidirectionalConnectionOpenable<DATA,INPUT>
,org.refcodes.component.BidirectionalConnectionOpenable.BidirectionalConnectionOpenAutomaton<DATA,INPUT>
,org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseAutomaton
,org.refcodes.component.ClosedAccessor
,org.refcodes.component.ConnectableComponent
,org.refcodes.component.ConnectableComponent.ConnectableAutomaton
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.Flushable
,org.refcodes.component.OpenedAccessor
,BidirectionalConnectionTransceiver<DATA,InputStream,OutputStream>
,BidirectionalStreamConnectionTransceiver<DATA>
,BlockConsumer<DATA>
,BlockProvider<DATA>
,BlockReceiver<DATA>
,BlockSender<DATA>
,Consumer<DATA>
,DatagramConsumer<DATA>
,DatagramProvider<DATA>
,DatagramReceiver<DATA>
,DatagramSender<DATA>
,DatagramTransceiver<DATA>
,Provider<DATA>
,Receivable
,Receiver<DATA>
,Sendable
,Sender<DATA>
,Transceiver<DATA>
,org.refcodes.mixin.Releaseable
public class PrefetchBidirectionalStreamConnectionTransceiverImpl<DATA extends Serializable> extends AbstractPrefetchInputStreamReceiver<DATA> implements BidirectionalStreamConnectionTransceiver<DATA>
The Class PrefetchBidirectionalStreamConnectionTransceiverImpl.- Author:
- steiner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.component.BidirectionalConnectionComponent
org.refcodes.component.BidirectionalConnectionComponent.BidirectionalConnectionAutomaton<INPUT extends Object,OUTPUT extends Object>
-
Nested classes/interfaces inherited from interface org.refcodes.component.BidirectionalConnectionOpenable
org.refcodes.component.BidirectionalConnectionOpenable.BidirectionalConnectionOpenAutomaton<INPUT extends Object,OUTPUT extends Object>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
-
-
Field Summary
-
Fields inherited from class org.refcodes.io.AbstractReceiver
DATAGRAM_QUEUE_SIZE
-
-
Constructor Summary
Constructors Constructor Description PrefetchBidirectionalStreamConnectionTransceiverImpl()
Instantiates a new prefetch bidirectional stream connection transceiver impl.PrefetchBidirectionalStreamConnectionTransceiverImpl(ExecutorService aExecutorService)
Instantiates a new prefetch bidirectional stream connection transceiver impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
boolean
isOpenable(InputStream aInputStream, OutputStream aOutputStream)
void
open(InputStream aInputStream, OutputStream aOutputStream)
protected void
open(OutputStream aOutputStream)
HINT: For testing purposes you can pass an already flushedObjectOutputStream
(viaObjectOutputStream.flush()
) encapsulating aPipedOutputStream
which in turn encapsulates aPipedInputStream
to thisopen(OutputStream)
method.void
writeDatagram(DATA aDatagram)
Writes (sends) a datagram to a listeningDatagramReceiver
.-
Methods inherited from class org.refcodes.component.AbstractConnectableAutomaton
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
-
Methods inherited from class org.refcodes.io.AbstractPrefetchInputStreamReceiver
isOpenable, open
-
Methods inherited from class org.refcodes.io.AbstractReceiver
hasDatagram, pushDatagram, pushDatagrams, pushDatagrams, readDatagram, readDatagrams, releaseAll
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isConnectionOpened
-
Methods inherited from interface org.refcodes.io.Consumer
writeDatagrams
-
Methods inherited from interface org.refcodes.io.DatagramProvider
readDatagram
-
Methods inherited from interface org.refcodes.mixin.Loggable
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.io.Receivable
hasDatagram
-
Methods inherited from interface org.refcodes.io.Receiver
readDatagrams, readDatagrams
-
Methods inherited from interface org.refcodes.io.Sender
writeDatagrams
-
-
-
-
Constructor Detail
-
PrefetchBidirectionalStreamConnectionTransceiverImpl
public PrefetchBidirectionalStreamConnectionTransceiverImpl()
Instantiates a new prefetch bidirectional stream connection transceiver impl.
-
PrefetchBidirectionalStreamConnectionTransceiverImpl
public PrefetchBidirectionalStreamConnectionTransceiverImpl(ExecutorService aExecutorService)
Instantiates a new prefetch bidirectional stream connection transceiver impl.- Parameters:
aExecutorService
- the executor service
-
-
Method Detail
-
isOpenable
public boolean isOpenable(InputStream aInputStream, OutputStream aOutputStream)
- Specified by:
isOpenable
in interfaceorg.refcodes.component.BidirectionalConnectionOpenable.BidirectionalConnectionOpenAutomaton<DATA extends Serializable,INPUT>
-
open
public void open(InputStream aInputStream, OutputStream aOutputStream) throws org.refcodes.component.OpenException
- Specified by:
open
in interfaceorg.refcodes.component.BidirectionalConnectionOpenable<DATA extends Serializable,INPUT>
- Throws:
org.refcodes.component.OpenException
-
writeDatagram
public void writeDatagram(DATA aDatagram) throws org.refcodes.component.OpenException
Writes (sends) a datagram to a listeningDatagramReceiver
.- Specified by:
writeDatagram
in interfaceConsumer<DATA extends Serializable>
- Specified by:
writeDatagram
in interfaceDatagramConsumer<DATA extends Serializable>
- Parameters:
aDatagram
- The datagram to be pushed to the receivingDatagramConsumer
.- Throws:
org.refcodes.component.OpenException
- Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
-
flush
public void flush() throws org.refcodes.component.OpenException
-
close
public void close() throws org.refcodes.component.CloseException
- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Overrides:
close
in classAbstractPrefetchInputStreamReceiver<DATA extends Serializable>
- Throws:
org.refcodes.component.CloseException
-
open
protected void open(OutputStream aOutputStream) throws org.refcodes.component.OpenException
HINT: For testing purposes you can pass an already flushedObjectOutputStream
(viaObjectOutputStream.flush()
) encapsulating aPipedOutputStream
which in turn encapsulates aPipedInputStream
to thisopen(OutputStream)
method. This enables you a non-blocking test of theOutputStreamConnectionSenderImpl
connected with thePrefetchInputStreamConnectionReceiverImpl
counterpart which is being opened with thePipedInputStream
. ATTENTION: For maintainers, please keep the below code in sync with the code fromOutputStreamConnectionSenderImpl.open(java.io.OutputStream)
; except do not set the connection status here, make it protected and do not @Override anything.- Parameters:
aOutputStream
- the output stream- Throws:
org.refcodes.component.OpenException
- the open exception
-
-