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 Summary
FieldsFields inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase
APPLICATION_SEPARATOR, DEFAULT_APPLICATION_INSTANCE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<O> voidattachIngestor(Class<O> outCls, String outTypeName, DataIngestor<O> ingestor) Attaches an asynchronous result data ingestor.protected GenericMultiTypeServiceImplgetImpl()Returns the multi-type implementation instance.protected static de.iip_ecosphere.platform.support.logging.LoggerReturns the logger.getOutTypeName(String inTypeName) Returns a registered output type name for a given input type name.protected <O> voidhandleResult(Class<O> cls, String data, String typeName) Handles a received processing result and ingests it back asynchronously.<I> voidRequests asynchronous processing a data item.protected abstract voidprocessImpl(String inType, String data) Actually processes the data by the service.<I,O> O processSync(String inTypeName, I data, String outTypeName) Requests synchronous processing a data item.voidregisterInOutRelation(String inTypeName, String outTypeName) Explicitly registers the relation between two type names.<I> voidregisterInputTypeTranslator(Class<I> inCls, String inTypeName, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<I, String> inTrans) Adds an input type translator.<O> voidregisterOutputTypeTranslator(Class<O> outCls, String outTypeName, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<String, O> outTrans) Adds an output type translator.Methods inherited from class de.iip_ecosphere.platform.services.environment.AbstractDelegatingService
activate, assignService, createService, getDescription, getId, getKind, getName, getService, getState, getVersion, initService, isDeployable, isTopLevel, migrate, passivate, reconfigure, setState, switchTo, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.services.environment.GenericMultiTypeService
processQuiet, processSyncQuietMethods inherited from interface de.iip_ecosphere.platform.services.environment.Service
activate, addTypeSubstitution, createType, createType, getDescription, getKind, getName, getNetMgtKeyAddress, getParameterConfigurer, getParameterNames, getSubstitutedType, getTypeCreator, getTypeSubstitutions, getVersion, isDeployable, isTopLevel, migrate, passivate, reconfigure, switchTo, updateMethods inherited from interface de.iip_ecosphere.platform.services.environment.switching.ServiceBase
getId, getState, setState
-
Field Details
-
impl
-
-
Constructor Details
-
AbstractDelegatingMultiService
Creates an instance.- Parameters:
yaml- the service description YAML
-
-
Method Details
-
handleResult
Handles a received processing result and ingests it back asynchronously.- Type Parameters:
O- the data type- Parameters:
cls- the data type classdata- the serialized datatypeName- 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:GenericMultiTypeServiceAdds an input type translator.- Specified by:
registerInputTypeTranslatorin interfaceGenericMultiTypeService- Type Parameters:
I- the input data type- Parameters:
inCls- the class representing the input typeinTypeName- symbolic name ofinCls, e.g. from configuration modelinTrans- 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:GenericMultiTypeServiceAdds an output type translator.- Specified by:
registerOutputTypeTranslatorin interfaceGenericMultiTypeService- Type Parameters:
O- the output data type- Parameters:
outCls- the class representing the input typeoutTypeName- symbolic name ofoutCls, e.g. from configuration modeloutTrans- the output data type translator- See Also:
-
attachIngestor
Description copied from interface:GenericMultiTypeServiceAttaches an asynchronous result data ingestor.- Specified by:
attachIngestorin interfaceGenericMultiTypeService- Type Parameters:
O- the output data type- Parameters:
outCls- the class representing the typeoutTypeName- symbolic name ofoutCls, e.g. from configuration modelingestor- the ingestor instance
-
registerInOutRelation
Description copied from interface:GenericMultiTypeServiceExplicitly registers the relation between two type names.- Specified by:
registerInOutRelationin interfaceGenericMultiTypeService- Parameters:
inTypeName- symbolic name of an input type, e.g. from configuration modeloutTypeName- symbolic name of an output type, e.g. from configuration model- See Also:
-
getOutTypeName
Description copied from interface:GenericMultiTypeServiceReturns a registered output type name for a given input type name.- Specified by:
getOutTypeNamein interfaceGenericMultiTypeService- Parameters:
inTypeName- the symbolic input type name- Returns:
- the related symbolic output type name, may be null if there is none
- See Also:
-
process
Description copied from interface:GenericMultiTypeServiceRequests asynchronous processing a data item.- Specified by:
processin interfaceGenericMultiTypeService- Type Parameters:
I- the input data type- Parameters:
inType- the name ofinTypein the configuration modeldata- 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
Actually processes the data by the service.- Parameters:
inType- the input typedata- 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:GenericMultiTypeServiceRequests synchronous processing a data item.- Specified by:
processSyncin interfaceGenericMultiTypeService- Type Parameters:
I- the input data typeO- the output data type- Parameters:
inTypeName- the name ofinTypein the configuration modeldata- the data item to be processedoutTypeName- the name ofoutTypein 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
Returns the multi-type implementation instance.- Returns:
- the implementation instance
-