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 Type
    Method
    Description
    void
    Attempts to establish a connection to the remote site.
    void
    disconnect(boolean dueToError)
    Drops the established connection.
    Gets gateway id (hostname, port, ...)
    long
    Gets last timestamp in unix millis when the last msg was received
    boolean
    Gets a value specifying whether the connection to the remote site is established.
    void
    sendData(byte[] data)
    Sends data through the current Gateway.
    void
    Sets the GatewayListener used to observe the current Gateway implementation.
  • Method Details

    • setListener

      void setListener(GatewayListener listener)
      Sets the GatewayListener used to observe the current Gateway implementation.
      Parameters:
      listener - the GatewayListener used to observe the current Gateway implementation or a null reference if observation is not required.
    • sendData

      void sendData(byte[] data) throws IOException
      Sends data through the current Gateway.
      Parameters:
      data - data to send.
      Throws:
      IllegalArgumentException - The data is a null reference or an empty array
      IOException - 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