Class AbstractChannelConnector<O,I,CO,CI>
- java.lang.Object
-
- de.iip_ecosphere.platform.connectors.AbstractConnector<O,I,CO,CI>
-
- de.iip_ecosphere.platform.connectors.AbstractChannelConnector<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:
Connector<O,I,CO,CI>,EventHandlingConnector,AbstractModelAccess.NotificationChangedListener
public abstract class AbstractChannelConnector<O,I,CO,CI> extends AbstractConnector<O,I,CO,CI>
Defines a basic channeled connector.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAbstractChannelConnector.ChannelAdapterProviderRefines the parent'sAbstractConnector.BasicAdapterProviderto comply with/providerChannelProtocolAdapter.-
Nested classes/interfaces inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
AbstractConnector.BasicAdapterProvider
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]outputChannelsprivate ChannelAdapterSelector<O,I,CO,CI>selector-
Fields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
DEFAULT_CHANNEL
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractChannelConnector(ChannelAdapterSelector<O,I,CO,CI> selector, ChannelProtocolAdapter<O,I,CO,CI>... adapter)Creates an instance and installs the protocol adapter.protectedAbstractChannelConnector(ChannelProtocolAdapter<O,I,CO,CI>... adapter)Creates an instance and installs the protocol adapter.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static <O,I,CO,CI>
ChannelAdapterSelector<O,I,CO,CI>ensureAdapterSelector(ChannelAdapterSelector<O,I,CO,CI> selector)Ensures that there is at least a default first-adapter selector of the right type.protected java.lang.String[]getOutputChannels()Returns the output channel names.protected ChannelAdapterSelector<O,I,CO,CI>getSelector()Returns the adapter selector.protected voidinitSelector(AdapterSelector<O,I,CO,CI> selector)CallsAdapterSelector.init(de.iip_ecosphere.platform.connectors.AdapterSelector.AdapterProvider)with a provider instance pointing to the adapters in this instance.COrequest(java.lang.String channel, boolean notifyCallback)Explicitly requests reading data from the source.voidwrite(CI data)Writes the givendatato the underlying machine/platform.protected voidwriteImpl(I data)Does the actual writing to the underlying machine/platform.protected abstract voidwriteImpl(I data, java.lang.String channel)Does the actual writing to the underlying machine/platform.-
Methods inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
checkCache, configureModelAccess, connect, connectImpl, createTlsContext, disconnect, disconnectImpl, doPolling, enableNotifications, enablePolling, error, getCachingStrategy, getCachingStrategyCls, getConnectorInputType, getConnectorOutputType, getConnectorParameter, getInitCachingStrategyCls, getProtocolInputType, getProtocolOutputType, initializeModelAccess, installPollTask, isPolling, notificationsChanged, notifyReconfigured, read, received, received, request, setReceptionCallback, trigger, trigger, uninstallPollTask, useTls
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.iip_ecosphere.platform.connectors.Connector
dispose, enabledEncryption, supportedEncryption
-
Methods inherited from interface de.iip_ecosphere.platform.connectors.events.EventHandlingConnector
getName
-
-
-
-
Field Detail
-
outputChannels
private java.lang.String[] outputChannels
-
selector
private ChannelAdapterSelector<O,I,CO,CI> selector
-
-
Constructor Detail
-
AbstractChannelConnector
@SafeVarargs protected AbstractChannelConnector(ChannelProtocolAdapter<O,I,CO,CI>... adapter)
Creates an instance and installs the protocol adapter.- Parameters:
adapter- the protocol adapter- Throws:
java.lang.IllegalArgumentException- ifadapteris null or empty or adapters are null
-
AbstractChannelConnector
@SafeVarargs protected AbstractChannelConnector(ChannelAdapterSelector<O,I,CO,CI> selector, ChannelProtocolAdapter<O,I,CO,CI>... adapter)
Creates an instance and installs the protocol adapter.- Parameters:
selector- the adapter selector (null leads to a default selector for the first adapter)adapter- the protocol adapter- Throws:
java.lang.IllegalArgumentException- ifadapteris null or empty or adapters are null
-
-
Method Detail
-
ensureAdapterSelector
private static <O,I,CO,CI> ChannelAdapterSelector<O,I,CO,CI> ensureAdapterSelector(ChannelAdapterSelector<O,I,CO,CI> selector)
Ensures that there is at least a default first-adapter selector of the right type.- 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- Parameters:
selector- the adapter selector (null leads to a default selector for the first adapter)- Returns:
selectoror a default selector instance
-
initSelector
protected void initSelector(AdapterSelector<O,I,CO,CI> selector)
Description copied from class:AbstractConnectorCallsAdapterSelector.init(de.iip_ecosphere.platform.connectors.AdapterSelector.AdapterProvider)with a provider instance pointing to the adapters in this instance.- Overrides:
initSelectorin classAbstractConnector<O,I,CO,CI>- Parameters:
selector- the selector to initialize
-
getSelector
protected ChannelAdapterSelector<O,I,CO,CI> getSelector()
Returns the adapter selector.- Overrides:
getSelectorin classAbstractConnector<O,I,CO,CI>- Returns:
- the selector
-
request
public CO request(java.lang.String channel, boolean notifyCallback) 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.- Overrides:
requestin classAbstractConnector<O,I,CO,CI>- Parameters:
channel- the channel to assign the received data to, may beAbstractConnector.DEFAULT_CHANNEL.notifyCallback- whetherthe reception callbackshall 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
public void write(CI data) throws java.io.IOException
Description copied from interface:ConnectorWrites the givendatato the underlying machine/platform.
-
writeImpl
protected final void writeImpl(I data) throws java.io.IOException
Description copied from class:AbstractConnectorDoes the actual writing to the underlying machine/platform. Can be left empty ifMachineConnector.hasModel().
-
writeImpl
protected abstract void writeImpl(I data, java.lang.String channel) throws java.io.IOException
Does the actual writing to the underlying machine/platform. Can be left empty ifMachineConnector.hasModel().- Parameters:
data- the data to be sendchannel- the channel name to use- Throws:
java.io.IOException- if sending fails
-
getOutputChannels
protected java.lang.String[] getOutputChannels()
Returns the output channel names.- Returns:
- the output channel names
-
-