Class AbstractDelegatingMultiService<S extends Service>

java.lang.Object
de.iip_ecosphere.platform.services.environment.AbstractDelegatingService<S>
de.iip_ecosphere.platform.services.environment.AbstractDelegatingMultiService<S>
Type Parameters:
S - the type of service to delegate to
All Implemented Interfaces:
GenericMultiTypeService, ParameterConfigurerProvider, Service, ServiceBase

public abstract class AbstractDelegatingMultiService<S extends Service> extends AbstractDelegatingService<S> implements GenericMultiTypeService
A multi-type service with an implementation based on a nested, delegated service as well as GenericMultiTypeServiceImpl.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • AbstractDelegatingMultiService

      public AbstractDelegatingMultiService(YamlService yaml)
      Creates an instance.
      Parameters:
      yaml - the service description YAML
  • Method Details

    • handleResult

      protected <O> void handleResult(Class<O> cls, String data, String typeName)
      Handles a received processing result and ingests it back asynchronously.
      Type Parameters:
      O - the data type
      Parameters:
      cls - the data type class
      data - the serialized data
      typeName - the data type name as specified in the configuration model
    • registerInputTypeTranslator

      public <I> void registerInputTypeTranslator(Class<I> inCls, String inTypeName, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I,String> inTrans)
      Description copied from interface: GenericMultiTypeService
      Adds an input type translator.
      Specified by:
      registerInputTypeTranslator in interface GenericMultiTypeService
      Type Parameters:
      I - the input data type
      Parameters:
      inCls - the class representing the input type
      inTypeName - symbolic name of inCls, e.g. from configuration model
      inTrans - the input data type translator
      See Also:
    • registerOutputTypeTranslator

      public <O> void registerOutputTypeTranslator(Class<O> outCls, String outTypeName, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<String,O> outTrans)
      Description copied from interface: GenericMultiTypeService
      Adds an output type translator.
      Specified by:
      registerOutputTypeTranslator in interface GenericMultiTypeService
      Type Parameters:
      O - the output data type
      Parameters:
      outCls - the class representing the input type
      outTypeName - symbolic name of outCls, e.g. from configuration model
      outTrans - the output data type translator
      See Also:
    • attachIngestor

      public <O> void attachIngestor(Class<O> outCls, String outTypeName, DataIngestor<O> ingestor)
      Description copied from interface: GenericMultiTypeService
      Attaches an asynchronous result data ingestor.
      Specified by:
      attachIngestor in interface GenericMultiTypeService
      Type Parameters:
      O - the output data type
      Parameters:
      outCls - the class representing the type
      outTypeName - symbolic name of outCls, e.g. from configuration model
      ingestor - the ingestor instance
    • registerInOutRelation

      public void registerInOutRelation(String inTypeName, String outTypeName)
      Description copied from interface: GenericMultiTypeService
      Explicitly registers the relation between two type names.
      Specified by:
      registerInOutRelation in interface GenericMultiTypeService
      Parameters:
      inTypeName - symbolic name of an input type, e.g. from configuration model
      outTypeName - symbolic name of an output type, e.g. from configuration model
      See Also:
    • getOutTypeName

      public String getOutTypeName(String inTypeName)
      Description copied from interface: GenericMultiTypeService
      Returns a registered output type name for a given input type name.
      Specified by:
      getOutTypeName in interface GenericMultiTypeService
      Parameters:
      inTypeName - the symbolic input type name
      Returns:
      the related symbolic output type name, may be null if there is none
      See Also:
    • process

      public <I> void process(String inType, I data) throws ExecutionException
      Description copied from interface: GenericMultiTypeService
      Requests asynchronous processing a data item.
      Specified by:
      process in interface GenericMultiTypeService
      Type Parameters:
      I - the input data type
      Parameters:
      inType - the name of inType in the configuration model
      data - the data item to be processed
      Throws:
      ExecutionException - if the execution fails for some reason, e.g., because type translators are not registered (@link #registerInputTypeTranslator(Class, Class, TypeTranslator, TypeTranslator)}
    • processImpl

      protected abstract void processImpl(String inType, String data) throws IOException
      Actually processes the data by the service.
      Parameters:
      inType - the input type
      data - the serialized to be processed data
      Throws:
      IOException - if processing fails
    • processSync

      public <I, O> O processSync(String inTypeName, I data, String outTypeName) throws ExecutionException
      Description copied from interface: GenericMultiTypeService
      Requests synchronous processing a data item.
      Specified by:
      processSync in interface GenericMultiTypeService
      Type Parameters:
      I - the input data type
      O - the output data type
      Parameters:
      inTypeName - the name of inType in the configuration model
      data - the data item to be processed
      outTypeName - the name of outType in the configuration model
      Returns:
      the output, always null in case of asynchronous processing as the result is passed to a registered ingestor
      Throws:
      ExecutionException - if the execution fails for some reason, e.g., because type translators are not registered (@link #registerInputTypeTranslator(Class, Class, TypeTranslator, TypeTranslator)}
    • getLogger

      protected static de.iip_ecosphere.platform.support.logging.Logger getLogger()
      Returns the logger.
      Returns:
      the logger
    • getImpl

      protected GenericMultiTypeServiceImpl getImpl()
      Returns the multi-type implementation instance.
      Returns:
      the implementation instance