Class VabIipOperationsProvider
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,Object>
de.iip_ecosphere.platform.support.aas.basyx.VabIipOperationsProvider
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,Object>
public class VabIipOperationsProvider extends HashMap<String,Object>
Implements a simple VAB operations provider following a simple status/operations/service structure
as the VABMapProvider. The idea is to attach the relevant operations of an implementing object to
this provider, whereby the implementing object is actually providing the functionality and this provider
just acts as an intermediary. For this purpose, you can register function objects for operations and
supplier/consumer objects of the implementing object in the provider. The provider then offers the respective
access under
- "status"/propertyName
- "operations"/"service"/operationName
constant.
The respective invocables must follow this naming schema for access.
An instance of this class can be used as a kind of implicit builder, i.e., operations to define properties and
operations return the instance the operation is called on. Ultimately, call createModelProvider() which
turns this instance into a model provider to be utilized to create a server.- Author:
- Holger Eichelberger, SSE
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classVabIipOperationsProvider.EntryAn entry as last element of a potentially hierarchically nested access path.private static classVabIipOperationsProvider.KindThe main kinds of entries.private static classVabIipOperationsProvider.PropertyRepresents a property consisting of a consumer and a supplier function.private classVabIipOperationsProvider.VABElementHandlerDefines the implementation to handle VAB elements, i.e., the mappings to the defined operations and functions.(package private) static classVabIipOperationsProvider.VabIipOperationsBuilderThe protocol server builder for this provider.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object> -
Field Summary
Fields Modifier and Type Field Description private Map<String,Function<Object[],Object>>operationFunctionsprivate Map<String,Map<String,VabIipOperationsProvider.Entry>>operationsstatic StringOPERATIONSThe path prefix for operations.static StringPREFIX_OPERATIONSA convenient combination ofOPERATIONS+SEPARATOR.static StringPREFIX_SERVICEstatic StringPREFIX_STATUSprivate Map<String,VabIipOperationsProvider.Property>propertiesstatic StringSEPARATORThe path separator.private static longserialVersionUIDprivate Map<String,VabIipOperationsProvider.Entry>servicestatic StringSERVICEThe operations category sub-path for operations.private Map<String,VabIipOperationsProvider.Entry>statusstatic StringSTATUSThe path prefix for status/properties. -
Constructor Summary
Constructors Constructor Description VabIipOperationsProvider()Creates a VAB operations provider instance. -
Method Summary
Modifier and Type Method Description org.eclipse.basyx.vab.modelprovider.generic.VABModelProvidercreateModelProvider()Ultimately creates the model provider.VabIipOperationsProviderdefineOperation(String category, String name, Function<Object[],Object> function)Defines an operation.VabIipOperationsProviderdefineProperty(String name, Supplier<Object> get, Consumer<Object> set)Defines a property with getter/setter implementation within "status".VabIipOperationsProviderdefineServiceFunction(String name, Function<Object[],Object> function)Defines a service function (i.e., in "operations"/"service").protected StringgetOperationsPath()Returns the base path name for operations.protected StringgetServicePath()Returns the base (sub-)path name for services.protected StringgetStatusPath()Returns the base path name for status/properties.private StringmakeUnique(Map<String,?> map, String baseName)Makes a name unique within its kind, i.e., the given map.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Field Details
-
SEPARATOR
The path separator.- See Also:
- Constant Field Values
-
STATUS
The path prefix for status/properties.- See Also:
- Constant Field Values
-
PREFIX_STATUS
- See Also:
- Constant Field Values
-
OPERATIONS
The path prefix for operations.- See Also:
- Constant Field Values
-
PREFIX_OPERATIONS
A convenient combination ofOPERATIONS+SEPARATOR.- See Also:
- Constant Field Values
-
SERVICE
The operations category sub-path for operations.- See Also:
- Constant Field Values
-
PREFIX_SERVICE
- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
status
-
operations
-
service
-
properties
-
operationFunctions
-
-
Constructor Details
-
VabIipOperationsProvider
public VabIipOperationsProvider()Creates a VAB operations provider instance.
-
-
Method Details
-
getStatusPath
Returns the base path name for status/properties. Allows for overriding the default settings.- Returns:
- the path name, by default
STATUS
-
getOperationsPath
Returns the base path name for operations. Allows for overriding the default settings.- Returns:
- the path name, by default
OPERATIONS
-
getServicePath
Returns the base (sub-)path name for services. Allows for overriding the default settings.- Returns:
- the path name, by default
SERVICE(interpreted as sub-path ofgetOperationsPath().
-
createModelProvider
public org.eclipse.basyx.vab.modelprovider.generic.VABModelProvider createModelProvider()Ultimately creates the model provider.- Returns:
- the model provider
-
makeUnique
Makes a name unique within its kind, i.e., the given map.- Parameters:
map- the mapbaseName- the (base) name to be made unique- Returns:
- the unique name
-
defineOperation
public VabIipOperationsProvider defineOperation(String category, String name, Function<Object[],Object> function)Defines an operation.- Parameters:
category- the category within "operations"name- the name of the operationfunction- the implementing function- Returns:
- this
- Throws:
IllegalArgumentException- if the operation is already registered
-
defineServiceFunction
public VabIipOperationsProvider defineServiceFunction(String name, Function<Object[],Object> function)Defines a service function (i.e., in "operations"/"service").- Parameters:
name- the name of the operationfunction- the implementing function- Returns:
- this
- Throws:
IllegalArgumentException- if the operation is already registered- See Also:
defineOperation(String, String, Function)
-
defineProperty
public VabIipOperationsProvider defineProperty(String name, Supplier<Object> get, Consumer<Object> set)Defines a property with getter/setter implementation within "status". Theoretically, either getter/setter may be null for read-only/write-only properties, but this must be, however, reflected in the AAS so that no wrong can access happens.- Parameters:
name- the name of the propertyget- the supplier providing read access to the property value (may be null)set- the consumer providing write access to the property value (may be null)- Returns:
- this
- Throws:
IllegalArgumentException- if the property is already registered
-