Class TransportConverter<T>
java.lang.Object
de.iip_ecosphere.platform.services.environment.services.TransportConverter<T>
- Type Parameters:
T- the data type
- Direct Known Subclasses:
TransportToAasConverter,TransportToWsConverter
Implements a generic converter from transport stream entries to some protocol.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a pair of server/converter created together.private classA trace reception callback callinghandleNew(Object)in own threads.static interfaceWatches for updates. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransportConverter(String transportStream, Class<T> dataType) Creates a service instance.Creates a service instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEndpointToAas(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder smBuilder, de.iip_ecosphere.platform.support.Endpoint endpoint) Adds an endpoint to a given (endpoint) submodel/elements collection.voidaddNotifier(de.iip_ecosphere.platform.support.function.IOConsumer<T> notifier) Defines a new notifier which is called when new data arrives.booleancleanup()Pursues a cleanup of the internal data structures, if applicable.abstract TransportConverter.Watcher<T> createWatcher(int period) Creates a watcher instance.de.iip_ecosphere.platform.support.EndpointReturns the server endpoint to connect to.static de.iip_ecosphere.platform.support.aas.SubmodelElementCollectiongetEndpoint(de.iip_ecosphere.platform.support.aas.ElementContainer parent, String path) Returns an AAS submodel element collection representing an endpoint.static de.iip_ecosphere.platform.support.EndpointgetEndpoint(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection endpoint) Turns a submodel element collection with endpoint information into an endpoint object.protected String[]Returns the excluded fields array.getType()Returns the handled data type.protected ObjectObtains the value return bymethodonpayload.protected abstract voidHandles a new trace record.private voidhandleNewAndNotify(T data) Handles a new trace record by callinghandleNew(Object)upon arrival.voidinitializeSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Initializes the submodel.protected booleanReturns whether the converter functionality shall be enabled.booleanReturns whether the AAS was started/startup is done.booleanisExcludedField(String fieldName) Returns whetherfieldNameis excluded.protected static booleanReturns whethermethodis an usual getter.booleanReturns whether traced data is directly stored in the AAS or not.protected StringmapPayloadType(Class<?> cls) Allows for application specific payload type names.voidsetAasEnabledSupplier(Supplier<Boolean> enabledSupplier) Changes the optional supplier for the AAS enabled state.voidsetCleanupTimeout(long cleanupTimeout) Changes the cleanup timeout, i.e., the time between two cleanups.voidsetExcludedFields(Set<String> excludedFields) Sets the excluded fields forhandleNew(Object).voidsetHandleNewFilter(Predicate<T> handleNewFilter) Sets a filter forhandleNew(Object).voidsetTimeout(long timeout) Changes the timeout until trace events are deleted.voidstart(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup) Starts the transport tracer.voidstop()Stops the transport, deletes the AAS.static StringtoAasEndpointId(String path) Turns an URI path into an endpoint AAS idShort.
-
Field Details
-
NAME_COLL_ENDPOINTS
- See Also:
-
NAME_PROP_SCHEMA
- See Also:
-
NAME_PROP_HOST
- See Also:
-
NAME_PROP_PORT
- See Also:
-
NAME_PROP_PATH
- See Also:
-
NAME_PROP_URI
- See Also:
-
PREFIX_GETTER
- See Also:
-
callback
-
notifier
-
transportStream
-
dataType
-
handleNewFilter
-
aasEnabledSupplier
-
excludedFields
-
executorService
-
-
Constructor Details
-
TransportConverter
Creates a service instance.- Parameters:
transportStream- the transport stream to be observed (name of the stream)dataType- the type of the data in the transport stream
-
TransportConverter
Creates a service instance.- Parameters:
transportStream- the transport stream to be observed (name of the stream)dataType- the type of the data in the transport streamhandleNewFilter- filter forhandleNew(Object), may be null
-
-
Method Details
-
setHandleNewFilter
Sets a filter forhandleNew(Object).- Parameters:
handleNewFilter- filter forhandleNew(Object), may be null
-
setExcludedFields
Sets the excluded fields forhandleNew(Object).- Parameters:
excludedFields- the excluded fields, may be null or empty for none
-
isExcludedField
Returns whetherfieldNameis excluded.- Parameters:
fieldName- the name of the field- Returns:
truefor excluded,falseelse
-
getExcludedFieldsArray
Returns the excluded fields array.- Returns:
- the excluded fields as array
-
addNotifier
Defines a new notifier which is called when new data arrives. Currently only one notifier is supported.- Parameters:
notifier- the notifier, ignored if null
-
handleNew
Handles a new trace record. Called upon arrival. [protected for mocking]- Parameters:
data- the trace record data
-
handleNewAndNotify
Handles a new trace record by callinghandleNew(Object)upon arrival. Entry point for handling new data, callinghandleNew(Object)to ensure thatnotifierare processed.- Parameters:
data- the trace record data
-
getValue
Obtains the value return bymethodonpayload.- Parameters:
object- the object to call the method onmethod- the method to callfield- the represented field (for logging)- Returns:
- the value of
fieldviamethod
-
mapPayloadType
Allows for application specific payload type names.- Parameters:
cls- the type- Returns:
- the mapped name
-
isGetter
Returns whethermethodis an usual getter.- Parameters:
method- the method to analyze- Returns:
truefor getter,falseelse
-
getType
Returns the handled data type.- Returns:
- the type
-
initializeSubmodel
public void initializeSubmodel(de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder smBuilder) Initializes the submodel.- Parameters:
smBuilder- the submodel builder
-
start
public void start(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup aasSetup) Starts the transport tracer.- Parameters:
aasSetup- the AAS setup to use
-
isAasEnabled
protected boolean isAasEnabled()Returns whether the converter functionality shall be enabled. [requires renaming]- Returns:
truefor enabled,falseelse
-
setAasEnabledSupplier
Changes the optional supplier for the AAS enabled state. [requires renaming]- Parameters:
enabledSupplier- the new supplier, ignored if null
-
isAasStarted
public boolean isAasStarted()Returns whether the AAS was started/startup is done.- Returns:
truefor started,falseelse
-
setTimeout
public void setTimeout(long timeout) Changes the timeout until trace events are deleted.- Parameters:
timeout- the timeout in ms
-
setCleanupTimeout
public void setCleanupTimeout(long cleanupTimeout) Changes the cleanup timeout, i.e., the time between two cleanups.- Parameters:
cleanupTimeout- the timeout in ms, disables cleanup if negative
-
cleanup
public boolean cleanup()Pursues a cleanup of the internal data structures, if applicable.- Returns:
- whether a cleanup process was executed (not whether elements were deleted)
-
stop
public void stop()Stops the transport, deletes the AAS. -
getEndpoint
public de.iip_ecosphere.platform.support.Endpoint getEndpoint()Returns the server endpoint to connect to.- Returns:
- the server endpoint, may be null for none, in particular if this connector is hosted by an AAS
-
isTraceInAas
public boolean isTraceInAas()Returns whether traced data is directly stored in the AAS or not.- Returns:
truefor traced data in AAS,falseelse
-
createWatcher
Creates a watcher instance.- Parameters:
period- the watching period in ms- Returns:
- the watcher
-
getEndpoint
public static de.iip_ecosphere.platform.support.aas.SubmodelElementCollection getEndpoint(de.iip_ecosphere.platform.support.aas.ElementContainer parent, String path) Returns an AAS submodel element collection representing an endpoint.- Parameters:
parent- the parent submodel or element collectionpath- the URI path used as id to represent the endpoint- Returns:
- the submodel element collection or null for none
-
getEndpoint
public static de.iip_ecosphere.platform.support.Endpoint getEndpoint(de.iip_ecosphere.platform.support.aas.SubmodelElementCollection endpoint) Turns a submodel element collection with endpoint information into an endpoint object.- Parameters:
endpoint- the submodel, e.g., fromgetEndpoint(ElementContainer, String)- Returns:
- the endpoint object, may be null if the object cannot be created
-
toAasEndpointId
Turns an URI path into an endpoint AAS idShort.- Parameters:
path- the path- Returns:
- the idShort
-
addEndpointToAas
public static void addEndpointToAas(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder smBuilder, de.iip_ecosphere.platform.support.Endpoint endpoint) Adds an endpoint to a given (endpoint) submodel/elements collection.- Parameters:
smBuilder- the submodel/elements collection builderendpoint- the endpoint, may be null
-