Interface Gateway
- All Known Implementing Classes:
ConnectionMonitoringGateway,ReconnectingGateway,TcpGateway
public interface Gateway
Represents a gateway capable of sending and receiving messages to or/and from other systems.
- Author:
- uros.bregar
-
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Attempts to establish a connection to the remote site.voiddisconnect(boolean dueToError) Drops the established connection.getId()Gets gateway id (hostname, port, ...)longGets last timestamp in unix millis when the last msg was receivedbooleanGets a value specifying whether the connection to the remote site is established.voidsendData(byte[] data) Sends data through the currentGateway.voidsetListener(GatewayListener listener) Sets theGatewayListenerused to observe the currentGatewayimplementation.
-
Method Details
-
setListener
Sets theGatewayListenerused to observe the currentGatewayimplementation.- Parameters:
listener- theGatewayListenerused to observe the currentGatewayimplementation or a null reference if observation is not required.
-
sendData
Sends data through the currentGateway.- Parameters:
data- data to send.- Throws:
IllegalArgumentException- Thedatais a null reference or an empty arrayIOException- connection problem
-
connect
Attempts to establish a connection to the remote site.- Throws:
IOException- There was an error establishing the connection.
-
disconnect
void disconnect(boolean dueToError) Drops the established connection.- Parameters:
dueToError- - when false user wished to close connection; when true there was a problem and we had to close it
-
isConnected
boolean isConnected()Gets a value specifying whether the connection to the remote site is established.- Returns:
- Value specifying whether the connection to the remote site is established.
-
getLastReceivedMsgTimestamp
long getLastReceivedMsgTimestamp()Gets last timestamp in unix millis when the last msg was received- Returns:
- timestamp when the last msg was received
-
getId
String getId()Gets gateway id (hostname, port, ...)- Returns:
- gateway identification
-