Class TransportConverterFactory

java.lang.Object
de.iip_ecosphere.platform.services.environment.services.TransportConverterFactory
Direct Known Subclasses:
WsTransportConverterFactory

public abstract class TransportConverterFactory extends Object
Creates instances for the transport converter service support.
Author:
Holger Eichelberger, SSE
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Network manager key for transport gateway.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final <T> TransportConverter<T>
    createConverter(de.iip_ecosphere.platform.support.Endpoint endpoint, String transportStream, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter instance.
    final <T> TransportConverter<T>
    createConverter(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String transportStream, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter instance.
    abstract <T> TransportConverter<T>
    createConverterImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, String transportStream, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter instance.
    final <T> Sender<T>
    createSender(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter sender instance.
    final <T> Sender<T>
    createSender(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter sender instance.
    protected abstract <T> Sender<T>
    createSenderImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Creates a converter sender instance.
    final de.iip_ecosphere.platform.support.Server
    createServer(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport)
    Creates a converter server instance.
    abstract de.iip_ecosphere.platform.support.Server
    createServer(de.iip_ecosphere.platform.support.ServerAddress address)
    Creates a converter server instance.
    createWatcher(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
    Creates a watcher instance.
    createWatcher(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
    Creates a watcher instance.
    protected abstract <T> TransportConverter.Watcher<T>
    createWatcherImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
    Creates a watcher instance.
    protected static <R> R
    createWithUri(de.iip_ecosphere.platform.support.Endpoint endpoint, Function<URI,R> creator)
    Creates some instance with a URI.
    protected <R> R
    createWithUri(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, Function<URI,R> creator)
    Creates some instance with a URI.
    static <T> de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String>
    ensureTranslator(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
    Ensures the existence of a translator instance.
    abstract de.iip_ecosphere.platform.support.Endpoint
    getGatewayEndpoint(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path)
    Returns an endpoint for the given path.
    Returns the actual factory instance.
    de.iip_ecosphere.platform.support.Endpoint
    validateGatewayEndpoint(de.iip_ecosphere.platform.support.Endpoint endpoint)
    Validates a gateway endpoint with respect to a modified ephemeral port.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • TransportConverterFactory

      public TransportConverterFactory()
  • Method Details

    • getInstance

      public static TransportConverterFactory getInstance()
      Returns the actual factory instance.
      Returns:
      the factor instance
    • createSender

      public final <T> Sender<T> createSender(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter sender instance. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Type Parameters:
      T - the type of data to be sent
      Parameters:
      aas - the AAS setup for AAS-based senders
      transport - the transport setup for transport-based senders
      path - within the mechanism to identify the data, may be an id short, an URI sub-path etc.
      translator - the type-to-sender format translator, may be null
      cls - the data type class
      Returns:
      the sender instance, may be null
      See Also:
    • createSender

      public final <T> Sender<T> createSender(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter sender instance.
      Type Parameters:
      T - the type of data to be sent
      Parameters:
      endpoint - the server endpoint
      translator - the type-to-sender format translator, may be null
      cls - the data type class
      Returns:
      the sender instance, may be null
      See Also:
    • createSenderImpl

      protected abstract <T> Sender<T> createSenderImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter sender instance.
      Type Parameters:
      T - the type of data to be sent
      Parameters:
      endpoint - the server endpoint
      translator - the type-to-sender format translator
      cls - the data type class
      Returns:
      the sender instance, may be null
    • createWatcher

      public final <T> TransportConverter.Watcher<T> createWatcher(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
      Creates a watcher instance. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      aas - the AAS setup for AAS-based watchers
      transport - the transport setup for transport-based watchers
      path - within the mechanism to identify the data, may be an id short, an URI sub-path etc.
      translator - the receiver-to-type format translator (may be null)
      cls - the data type class
      period - the watching period in ms
      Returns:
      the watcher instance, may be null
      See Also:
    • createWatcher

      public final <T> TransportConverter.Watcher<T> createWatcher(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
      Creates a watcher instance.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      endpoint - the server endpoint
      translator - the receiver-to-type format translator
      cls - the data type class
      period - the watching period in ms
      Returns:
      the watcher instance, may be null
      See Also:
    • createWatcherImpl

      protected abstract <T> TransportConverter.Watcher<T> createWatcherImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls, int period)
      Creates a watcher instance.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      endpoint - the server endpoint
      translator - the receiver-to-type format translator
      cls - the data type class
      period - the watching period in ms
      Returns:
      the watcher instance, may be null
    • createConverter

      public final <T> TransportConverter<T> createConverter(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String transportStream, String path, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter instance. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      aas - the AAS setup for AAS-based watchers
      transport - the transport setup for transport-based watchers
      transportStream - the stream to listen to
      path - within the mechanism to stream the data to, may be an id short, an URI sub-path etc.
      translator - the receiver-to-type format translator (may be null)
      cls - the data type class
      Returns:
      the converter instance, may be null
      See Also:
    • createConverter

      public final <T> TransportConverter<T> createConverter(de.iip_ecosphere.platform.support.Endpoint endpoint, String transportStream, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter instance. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      endpoint - the server endpoint
      transportStream - the stream to listen to
      translator - the receiver-to-type format translator (may be null)
      cls - the data type class
      Returns:
      the converter instance, may be null
      See Also:
    • createConverterImpl

      public abstract <T> TransportConverter<T> createConverterImpl(de.iip_ecosphere.platform.support.Endpoint endpoint, String transportStream, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Creates a converter instance. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Type Parameters:
      T - the type of data to be watched
      Parameters:
      endpoint - the server endpoint
      transportStream - the stream to listen to
      translator - the receiver-to-type format translator
      cls - the data type class
      Returns:
      the converter instance, may be null
    • ensureTranslator

      public static <T> de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> ensureTranslator(de.iip_ecosphere.platform.transport.serialization.TypeTranslator<T,String> translator, Class<T> cls)
      Ensures the existence of a translator instance. [public for testing]
      Type Parameters:
      T - the data type
      Parameters:
      translator - the type translator; if null, GenericJsonToStringTranslator is used
      cls - the data type class
      Returns:
      the type translator, either tanslator or a default instance
    • createWithUri

      protected <R> R createWithUri(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path, Function<URI,R> creator)
      Creates some instance with a URI.
      Type Parameters:
      R - the resulting instance type
      Parameters:
      aas - the AAS setup
      transport - the transport setup to take TransportSetup.getGatewayServerEndpoint(Schema, String) from
      path - the path for determining the gateway server endpoint
      creator - the creator function
      Returns:
      created instance, may be null
      See Also:
    • createWithUri

      protected static <R> R createWithUri(de.iip_ecosphere.platform.support.Endpoint endpoint, Function<URI,R> creator)
      Creates some instance with a URI.
      Type Parameters:
      R - the resulting instance type
      Parameters:
      endpoint - the endpoint to take the URI from
      creator - the creator function
      Returns:
      created instance, may be null
    • createServer

      public final de.iip_ecosphere.platform.support.Server createServer(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport)
      Creates a converter server instance. The implementing factory is free to choose which information to take and may fail if required information is not given. If the configured port is not positive, an ephemeral port will be used for creating the server.
      Parameters:
      aas - the AAS setup for AAS-based senders
      transport - the transport setup for transport-based senders, may be modified for emphemeral ports
      Returns:
      the server instance, may be null if none is required for the actual factory
      See Also:
    • createServer

      public abstract de.iip_ecosphere.platform.support.Server createServer(de.iip_ecosphere.platform.support.ServerAddress address)
      Creates a converter server instance.
      Parameters:
      address - the server address
      Returns:
      the server instance, may be null if none is required for the actual factory
    • getGatewayEndpoint

      public abstract de.iip_ecosphere.platform.support.Endpoint getGatewayEndpoint(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aas, de.iip_ecosphere.platform.transport.connectors.TransportSetup transport, String path)
      Returns an endpoint for the given path. The implementing factory is free to choose which information to take and may fail if required information is not given.
      Parameters:
      aas - the AAS setup for AAS-based senders
      transport - the transport setup for transport-based senders
      path - the path within the resulting endpoint
      Returns:
      the endpoint
    • validateGatewayEndpoint

      public de.iip_ecosphere.platform.support.Endpoint validateGatewayEndpoint(de.iip_ecosphere.platform.support.Endpoint endpoint)
      Validates a gateway endpoint with respect to a modified ephemeral port.
      Parameters:
      endpoint - the endpoint to validate
      Returns:
      endpoint or the validated/modified endpoint