Class TranslatingProtocolAdapter<O,I,CO,CI>
- java.lang.Object
-
- de.iip_ecosphere.platform.connectors.types.AbstractProtocolAdapter<O,I,CO,CI>
-
- de.iip_ecosphere.platform.connectors.types.TranslatingProtocolAdapter<O,I,CO,CI>
-
- Type Parameters:
O- the output type from the underlying machine/platformI- the input type to the underlying machine/platformCO- the output type of the connectorCI- the input type of the connector
- All Implemented Interfaces:
ProtocolAdapter<O,I,CO,CI>
- Direct Known Subclasses:
ChannelTranslatingProtocolAdapter
public class TranslatingProtocolAdapter<O,I,CO,CI> extends AbstractProtocolAdapter<O,I,CO,CI>
Uses twoTypeTranslatorinstances for the protocol adaptation, optionally passing on the reception channel to a givenChanneledConnectorOutputTypeTranslator.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private ChanneledConnectorOutputTypeTranslator<O,CO>channeledOutputTranslatorprivate ConnectorInputTypeTranslator<CI,I>inputTranslatorprivate ConnectorOutputTypeTranslator<O,CO>outputTranslator
-
Constructor Summary
Constructors Constructor Description TranslatingProtocolAdapter(ConnectorOutputTypeTranslator<O,CO> outputTranslator, ConnectorInputTypeTranslator<CI,I> inputTranslator)Creates a translating protocol adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IadaptInput(CI data)Adapts the input from the IIP-Ecosphere platform to the underlying machine/platform.COadaptOutput(java.lang.String channel, O data)Adapts the output from the underlying machine/platform to the IIP-Ecosphere platform.java.lang.Class<? extends CI>getConnectorInputType()Returns the input type from the IIP-Ecosphere platform.java.lang.Class<? extends CO>getConnectorOutputType()Returns the output type to the IIP-Ecosphere platform.java.lang.Class<? extends I>getProtocolInputType()Returns the input type to the protocol.java.lang.Class<? extends O>getProtocolOutputType()Returns the output type of the protocol.voidinitializeModelAccess()Called to initialize the model access, e.g., to setup notifications.voidsetModelAccess(ModelAccess modelAccess)Defines the model access.-
Methods inherited from class de.iip_ecosphere.platform.connectors.types.AbstractProtocolAdapter
getModelAccess
-
-
-
-
Field Detail
-
outputTranslator
private ConnectorOutputTypeTranslator<O,CO> outputTranslator
-
channeledOutputTranslator
private ChanneledConnectorOutputTypeTranslator<O,CO> channeledOutputTranslator
-
inputTranslator
private ConnectorInputTypeTranslator<CI,I> inputTranslator
-
-
Constructor Detail
-
TranslatingProtocolAdapter
public TranslatingProtocolAdapter(ConnectorOutputTypeTranslator<O,CO> outputTranslator, ConnectorInputTypeTranslator<CI,I> inputTranslator)
Creates a translating protocol adapter.- Parameters:
outputTranslator- the output translator, may be aChanneledConnectorOutputTypeTranslatorinputTranslator- the input translator
-
-
Method Detail
-
adaptInput
public I adaptInput(CI data) throws java.io.IOException
Description copied from interface:ProtocolAdapterAdapts the input from the IIP-Ecosphere platform to the underlying machine/platform.- Parameters:
data- the data to be adapted- Returns:
- the adapted data
- Throws:
java.io.IOException- in case that the adaptation fails
-
adaptOutput
public CO adaptOutput(java.lang.String channel, O data) throws java.io.IOException
Description copied from interface:ProtocolAdapterAdapts the output from the underlying machine/platform to the IIP-Ecosphere platform.- Parameters:
channel- the channel the data was receiveddata- the data to be adapted- Returns:
- the adapted data
- Throws:
java.io.IOException- in case that the adaptation fails
-
setModelAccess
public void setModelAccess(ModelAccess modelAccess)
Description copied from class:AbstractProtocolAdapterDefines the model access. Handle with care, shall be called by connector only.- Specified by:
setModelAccessin interfaceProtocolAdapter<O,I,CO,CI>- Overrides:
setModelAccessin classAbstractProtocolAdapter<O,I,CO,CI>- Parameters:
modelAccess- the model access
-
initializeModelAccess
public void initializeModelAccess() throws java.io.IOExceptionDescription copied from interface:ProtocolAdapterCalled to initialize the model access, e.g., to setup notifications. Called only, when the connector is connected.- Throws:
java.io.IOException- in case the initialization fails, e.g., monitors cannot be set up
-
getProtocolInputType
public java.lang.Class<? extends I> getProtocolInputType()
Description copied from interface:ProtocolAdapterReturns the input type to the protocol.- Returns:
- the input type (may be null in case of generic types, but shall not be null)
-
getConnectorInputType
public java.lang.Class<? extends CI> getConnectorInputType()
Description copied from interface:ProtocolAdapterReturns 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
public java.lang.Class<? extends O> getProtocolOutputType()
Description copied from interface:ProtocolAdapterReturns the output type of the protocol.- Returns:
- the output type (may be null in case of generic types, but shall not be null)
-
getConnectorOutputType
public java.lang.Class<? extends CO> getConnectorOutputType()
Description copied from interface:ProtocolAdapterReturns 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)
-
-