Interface Connector<O,​I,​CO,​CI>

  • Type Parameters:
    O - the output type from the underlying machine/platform
    I - the input type to the underlying machine/platform
    CO - the output type of the connector
    CI - the input type of the connector
    All Superinterfaces:
    EventHandlingConnector
    All Known Implementing Classes:
    AbstractChannelConnector, AbstractConnector

    public interface Connector<O,​I,​CO,​CI>
    extends EventHandlingConnector
    The interface of a platform/machine connector. A connector shall define a ConnectorDescriptor as top-level inner class and register the descriptor as service. By default, polling shall be enabled but in certain cases this may not fit into the lifecycle of services in a service environment. Then it is possible to explicitly enable/disable polling.
    Author:
    Holger Eichelberger, SSE
    • Method Detail

      • connect

        void connect​(ConnectorParameter params)
              throws java.io.IOException
        Connects the connector to the underlying machine/platform.
        Parameters:
        params - connection parameter
        Throws:
        java.io.IOException - in case that connecting fails
      • request

        CO request​(boolean sendToCallback)
            throws java.io.IOException
        Explicitly requests reading data from the source. This is typically done by polling or events, but, in seldom cases, may be needed manually.
        Parameters:
        sendToCallback - whether the reception callback shall be informed about new data
        Returns:
        the data from the machine, null for none, i.e., also no call to the reception callback
        Throws:
        java.io.IOException - in case that reading fails
      • write

        void write​(CI data)
            throws java.io.IOException
        Writes the given data to the underlying machine/platform.
        Parameters:
        data - the data to send to stream
        Throws:
        java.io.IOException - in case that problems during the connection happens
      • setReceptionCallback

        void setReceptionCallback​(de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<CO> callback)
                           throws java.io.IOException
        Attaches a reception callback to this connector. The callback is called upon a reception.
        Parameters:
        callback - the callback to attach
        Throws:
        java.io.IOException - in case that problems during registering the callback (e.g., during subscription) happens
      • disconnect

        void disconnect()
                 throws java.io.IOException
        Disconnects the connector from the underlying machine/platform.
        Throws:
        java.io.IOException - in case that connecting fails
      • dispose

        void dispose()
        Final cleanup when platform shuts down, e.g., for shared resources.
      • getProtocolInputType

        java.lang.Class<? extends I> getProtocolInputType()
        Returns the input type to the protocol.
        Returns:
        the input type (may be null in case of generic types, but shall not be null)
      • getConnectorInputType

        java.lang.Class<? extends CI> getConnectorInputType()
        Returns the input type from the IIP-Ecosphere platform.
        Returns:
        the input type (may be null in case of generic types, but shall not be null)
      • getProtocolOutputType

        java.lang.Class<? extends O> getProtocolOutputType()
        Returns the output type of the protocol.
        Returns:
        the output type (may be null in case of generic types, but shall not be null)
      • getConnectorOutputType

        java.lang.Class<? extends CO> getConnectorOutputType()
        Returns the output type to the IIP-Ecosphere platform.
        Returns:
        the output type (may be null in case of generic types, but shall not be null)
      • supportedEncryption

        java.lang.String supportedEncryption()
        Returns the supported encryption mechanisms.
        Returns:
        the supported encryption mechanisms (comma-separated), may be null or empty
      • enabledEncryption

        java.lang.String enabledEncryption()
        Returns the actually enabled encryption mechanisms on this instance. The result may change when connecting the connector.
        Returns:
        the enabled encryption mechanisms (comma-separated), may be null or empty
      • enableNotifications

        void enableNotifications​(boolean enableNotifications)
        Enables/disables notifications/polling at all.
        Parameters:
        enableNotifications - enable or disable notifications
      • getCachingStrategyCls

        default java.lang.Class<? extends CachingStrategy> getCachingStrategyCls()
        Returns the actual caching strategy class.
        Returns:
        the strategy class
      • notifyReconfigured

        default void notifyReconfigured​(java.lang.String parameterName,
                                        java.lang.String value)
        Called when parameters of the containing service are changed.
        Parameters:
        parameterName - the parameter name
        value - the new value