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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
connect()
Attempts to establish a connection to the remote site.void
disconnect(boolean dueToError)
Drops the established connection.String
getId()
Gets gateway id (hostname, port, ...)long
getLastReceivedMsgTimestamp()
Gets last timestamp in unix millis when the last msg was receivedboolean
isConnected()
Gets a value specifying whether the connection to the remote site is established.void
sendData(byte[] data)
Sends data through the currentGateway
.void
setListener(GatewayListener listener)
Sets theGatewayListener
used to observe the currentGateway
implementation.
-
-
-
Method Detail
-
setListener
void setListener(GatewayListener listener)
Sets theGatewayListener
used to observe the currentGateway
implementation.- Parameters:
listener
- theGatewayListener
used to observe the currentGateway
implementation or a null reference if observation is not required.
-
sendData
void sendData(byte[] data) throws IOException
Sends data through the currentGateway
.- Parameters:
data
- data to send.- Throws:
IllegalArgumentException
- Thedata
is a null reference or an empty arrayIOException
- connection problem
-
connect
void connect() throws IOException
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
-
-