Class FileConnector<CO,CI>
java.lang.Object
de.iip_ecosphere.platform.connectors.AbstractConnector<byte[],byte[],CO,CI>
de.iip_ecosphere.platform.connectors.AbstractChannelConnector<byte[],byte[],CO,CI>
de.oktoflow.platform.connectors.file.FileConnector<CO,CI>
- Type Parameters:
CO- the output type to the IIP-Ecosphere platformCI- the input type from the IIP-Ecosphere platform
- All Implemented Interfaces:
de.iip_ecosphere.platform.connectors.Connector<byte[],,byte[], CO, CI> de.iip_ecosphere.platform.connectors.events.EventHandlingConnector,de.iip_ecosphere.platform.connectors.model.AbstractModelAccess.NotificationChangedListener
@MachineConnector(hasModel=false,
supportsEvents=true,
supportsHierarchicalQNames=false,
supportsModelCalls=false,
supportsModelProperties=false,
supportsModelStructs=false,
specificSettings={},
supportsDataTimeDifference=true)
@MachineConnectorSupportedQueries(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery.class)
public class FileConnector<CO,CI>
extends de.iip_ecosphere.platform.connectors.AbstractChannelConnector<byte[],byte[],CO,CI>
Implements the generic file connector. Intended to use with appropriate data serializers or wrapped
InputParser/OutputFormatter considered by code generation, e.g., to realize a JSON or CSV
data connector. Do not rename, this class is referenced in META-INF/services.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe descriptor of this connector (see META-INF/services).Nested classes/interfaces inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
de.iip_ecosphere.platform.connectors.AbstractConnector.BasicAdapterProvider -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate intprivate static final de.iip_ecosphere.platform.support.logging.Loggerstatic final Stringprivate intprivate Map<String, PrintStream> static final Stringstatic final Stringprivate booleanprivate booleanprivate intprivate Stringprivate intstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate booleanprivate FileFields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
DEFAULT_CHANNEL -
Constructor Summary
ConstructorsConstructorDescriptionFileConnector(de.iip_ecosphere.platform.connectors.ChannelAdapterSelector<byte[], byte[], CO, CI> selector, de.iip_ecosphere.platform.connectors.types.ChannelProtocolAdapter<byte[], byte[], CO, CI>... adapter) Creates a connector instance.FileConnector(de.iip_ecosphere.platform.connectors.types.ChannelProtocolAdapter<byte[], byte[], CO, CI>... adapter) Creates a connector instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconnectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) protected voidvoiddispose()protected voidgetName()static FilenameFiltergetWriteFileNameFilter(boolean considerThread) Returns a file name filter for files being written ifSETTING_WRITE_FILESis a directory.protected voidnotifyDataTimeDifference(int difference) private BufferedReaderTries to openfileor, as fallback, as a resource.protected byte[]read()private voidreadData()Reads the data from all files line-by-line.voidtrigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query) protected voidMethods inherited from class de.iip_ecosphere.platform.connectors.AbstractChannelConnector
getOutputChannels, getSelector, initSelector, request, write, writeImplMethods inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
checkCache, configureAdapter, configureModelAccess, connect, createTlsContext, disconnect, doPolling, enableNotifications, enablePolling, getCachingStrategy, getCachingStrategyCls, getConnectorInputType, getConnectorOutputType, getConnectorParameter, getInitCachingStrategyCls, getInstanceIdentification, getProtocolInputType, getProtocolOutputType, getStorageValue, initializeModelAccess, installPollTask, isPolling, notificationsChanged, notifyReconfigured, received, received, request, setDataTimeDifference, setDataTimeDifferenceProvider, setInstanceIdentification, setReceptionCallback, setStorageValue, trigger, uninstallPollTask, useTlsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.connectors.Connector
createSharedSpace, disconnectSafe, enableSharedSpace, setReceptionCallbackSafe
-
Field Details
-
NAME
- See Also:
-
SETTING_READ_FILES
- See Also:
-
SETTING_WRITE_FILES
- See Also:
-
SETTING_DATA_TIMEDIFF
- See Also:
-
SETTING_SKIP_FIRST_LINE
- See Also:
-
OUT_NAME_PREFIX
- See Also:
-
OUT_NAME_SUFFIX
- See Also:
-
LOGGER
private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER -
readFiles
-
writeFiles
-
connected
private boolean connected -
out
-
outFailed
private boolean outFailed -
pollResult
-
polling
private boolean polling -
requestTimeout
private int requestTimeout -
pollingFrequency
private int pollingFrequency -
fixedDataInterval
private int fixedDataInterval -
nextDataInterval
private int nextDataInterval -
skipFirstLine
private boolean skipFirstLine
-
-
Constructor Details
-
FileConnector
@SafeVarargs public FileConnector(de.iip_ecosphere.platform.connectors.types.ChannelProtocolAdapter<byte[], byte[], CO, CI>... adapter) Creates a connector instance.- Parameters:
adapter- the protocol adapter(s)- Throws:
IllegalArgumentException- ifadapteris null or empty or adapters are null
-
FileConnector
@SafeVarargs public FileConnector(de.iip_ecosphere.platform.connectors.ChannelAdapterSelector<byte[], byte[], CO, CI> selector, de.iip_ecosphere.platform.connectors.types.ChannelProtocolAdapter<byte[], byte[], CO, CI>... adapter) Creates a connector instance.- Parameters:
selector- the adapter selector (null leads to a default selector for the first adapter)adapter- the protocol adapter(s)- Throws:
IllegalArgumentException- ifadapteris null or empty or adapters are null
-
-
Method Details
-
connectImpl
protected void connectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) throws IOException - Specified by:
connectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<byte[],byte[], CO, CI> - Throws:
IOException
-
open
Tries to openfileor, as fallback, as a resource.- Parameters:
file- the file to open- Returns:
- the opened stream
- Throws:
IOException- if openingfilefinally fails
-
readData
private void readData()Reads the data from all files line-by-line. -
notifyDataTimeDifference
protected void notifyDataTimeDifference(int difference) -
disconnectImpl
- Specified by:
disconnectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<byte[],byte[], CO, CI> - Throws:
IOException
-
dispose
public void dispose() -
getName
-
writeImpl
- Specified by:
writeImplin classde.iip_ecosphere.platform.connectors.AbstractChannelConnector<byte[],byte[], CO, CI> - Throws:
IOException
-
read
- Specified by:
readin classde.iip_ecosphere.platform.connectors.AbstractConnector<byte[],byte[], CO, CI> - Throws:
IOException
-
error
-
supportedEncryption
-
enabledEncryption
-
getWriteFileNameFilter
Returns a file name filter for files being written ifSETTING_WRITE_FILESis a directory.- Returns:
- the file name filter instance
-
trigger
public void trigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)
-