Package jadex.bridge.component.streams
Class OutputConnection
- java.lang.Object
-
- jadex.bridge.component.streams.AbstractConnection
-
- jadex.bridge.component.streams.OutputConnection
-
- All Implemented Interfaces:
IConnection
,IOutputConnection
public class OutputConnection extends AbstractConnection implements IOutputConnection
Output connection for writing data. Must synchronized its internal data because the connection handler and the connection user (i.e. a component) are using the connection concurrently. - the user calls interface methods like write and flush - the connection handler calls close to signal that the connection should close.
-
-
Field Summary
-
Fields inherited from class jadex.bridge.component.streams.AbstractConnection
ch, closed, closing, id, ini, inited, initiator, input, participant
-
-
Constructor Summary
Constructors Constructor Description OutputConnection(IComponentIdentifier sender, IComponentIdentifier receiver, int id, boolean initiator, IOutputConnectionHandler ch)
Create a new connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the connection.void
flush()
Flush the data.IFuture<java.lang.Integer>
waitForReady()
Wait until the connection is ready for the next write.IFuture<java.lang.Void>
write(byte[] data)
Write the content to the stream.ISubscriptionIntermediateFuture<java.lang.Long>
writeFromInputStream(java.io.InputStream is, IExternalAccess component)
Do write all data from the input stream.-
Methods inherited from class jadex.bridge.component.streams.AbstractConnection
getConnectionHandler, getConnectionId, getInitiator, getNonFunctionalProperties, getParticipant, isClosed, isClosing, isInited, isInitiatorSide, isInputConnection, setClosed, setClosing, setInited
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.bridge.IConnection
getConnectionId, getInitiator, getNonFunctionalProperties, getParticipant
-
-
-
-
Constructor Detail
-
OutputConnection
public OutputConnection(IComponentIdentifier sender, IComponentIdentifier receiver, int id, boolean initiator, IOutputConnectionHandler ch)
Create a new connection.
-
-
Method Detail
-
write
public IFuture<java.lang.Void> write(byte[] data)
Write the content to the stream.- Specified by:
write
in interfaceIOutputConnection
- Parameters:
data
- The data.
-
flush
public void flush()
Flush the data.- Specified by:
flush
in interfaceIOutputConnection
-
waitForReady
public IFuture<java.lang.Integer> waitForReady()
Wait until the connection is ready for the next write.- Specified by:
waitForReady
in interfaceIOutputConnection
- Returns:
- Calls future when next data can be written. Provides a value of how much data should be given to the connection for best performance.
-
close
public void close()
Close the connection. Notifies the other side that the connection has been closed.- Specified by:
close
in interfaceIConnection
- Overrides:
close
in classAbstractConnection
-
writeFromInputStream
public ISubscriptionIntermediateFuture<java.lang.Long> writeFromInputStream(java.io.InputStream is, IExternalAccess component)
Do write all data from the input stream.- Specified by:
writeFromInputStream
in interfaceIOutputConnection
- Parameters:
is
- The input stream.
-
-