Class VabOperationsProvider

  • All Implemented Interfaces:
    de.iip_ecosphere.platform.support.aas.OperationsProvider, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.Object>

    public class VabOperationsProvider
    extends java.util.HashMap<java.lang.String,​java.lang.Object>
    implements de.iip_ecosphere.platform.support.aas.OperationsProvider
    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 while ""service"" is just seen as a category of many potential operation categories that you can register. "/" is the VAB-defined path separator, which is available as 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 class  VabOperationsProvider.Entry
      An entry as last element of a potentially hierarchically nested access path.
      private static class  VabOperationsProvider.Kind
      The main kinds of entries.
      private static class  VabOperationsProvider.Property
      Represents a property consisting of a consumer and a supplier function.
      private class  VabOperationsProvider.VABElementHandler
      Defines the implementation to handle VAB elements, i.e., the mappings to the defined operations and functions.
      (package private) static class  VabOperationsProvider.VabHttpOperationsBuilder
      The protocol server builder for this provider.
      (package private) static class  VabOperationsProvider.VabTcpOperationsBuilder
      The protocol server builder for this provider.
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      VabOperationsProvider()
      Creates a VAB operations provider instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.eclipse.basyx.vab.modelprovider.generic.VABModelProvider createModelProvider()
      Ultimately creates the model provider.
      VabOperationsProvider defineOperation​(java.lang.String category, java.lang.String name, java.util.function.Function<java.lang.Object[],​java.lang.Object> function)  
      VabOperationsProvider defineProperty​(java.lang.String name, java.util.function.Supplier<java.lang.Object> get, java.util.function.Consumer<java.lang.Object> set)  
      VabOperationsProvider defineServiceFunction​(java.lang.String name, java.util.function.Function<java.lang.Object[],​java.lang.Object> function)  
      java.util.function.Supplier<java.lang.Object> getGetter​(java.lang.String name)  
      java.util.function.Function<java.lang.Object[],​java.lang.Object> getOperation​(java.lang.String category, java.lang.String name)  
      protected java.lang.String getOperationsPath()
      Returns the base path name for operations.
      java.util.function.Function<java.lang.Object[],​java.lang.Object> getServiceFunction​(java.lang.String name)  
      protected java.lang.String getServicePath()
      Returns the base (sub-)path name for services.
      java.util.function.Consumer<java.lang.Object> getSetter​(java.lang.String name)  
      protected java.lang.String getStatusPath()
      Returns the base path name for status/properties.
      private java.lang.String makeUnique​(java.util.Map<java.lang.String,​?> map, java.lang.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
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Constructor Detail

      • VabOperationsProvider

        public VabOperationsProvider()
        Creates a VAB operations provider instance.
    • Method Detail

      • getStatusPath

        protected java.lang.String getStatusPath()
        Returns the base path name for status/properties. Allows for overriding the default settings.
        Returns:
        the path name, by default STATUS
      • getOperationsPath

        protected java.lang.String getOperationsPath()
        Returns the base path name for operations. Allows for overriding the default settings.
        Returns:
        the path name, by default OPERATIONS
      • getServicePath

        protected java.lang.String 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 of getOperationsPath().
      • createModelProvider

        public org.eclipse.basyx.vab.modelprovider.generic.VABModelProvider createModelProvider()
        Ultimately creates the model provider.
        Returns:
        the model provider
      • makeUnique

        private java.lang.String makeUnique​(java.util.Map<java.lang.String,​?> map,
                                            java.lang.String baseName)
        Makes a name unique within its kind, i.e., the given map.
        Parameters:
        map - the map
        baseName - the (base) name to be made unique
        Returns:
        the unique name
      • defineOperation

        public VabOperationsProvider defineOperation​(java.lang.String category,
                                                     java.lang.String name,
                                                     java.util.function.Function<java.lang.Object[],​java.lang.Object> function)
        Specified by:
        defineOperation in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • getOperation

        public java.util.function.Function<java.lang.Object[],​java.lang.Object> getOperation​(java.lang.String category,
                                                                                                   java.lang.String name)
        Specified by:
        getOperation in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • getServiceFunction

        public java.util.function.Function<java.lang.Object[],​java.lang.Object> getServiceFunction​(java.lang.String name)
        Specified by:
        getServiceFunction in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • defineServiceFunction

        public VabOperationsProvider defineServiceFunction​(java.lang.String name,
                                                           java.util.function.Function<java.lang.Object[],​java.lang.Object> function)
        Specified by:
        defineServiceFunction in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • defineProperty

        public VabOperationsProvider defineProperty​(java.lang.String name,
                                                    java.util.function.Supplier<java.lang.Object> get,
                                                    java.util.function.Consumer<java.lang.Object> set)
        Specified by:
        defineProperty in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • getGetter

        public java.util.function.Supplier<java.lang.Object> getGetter​(java.lang.String name)
        Specified by:
        getGetter in interface de.iip_ecosphere.platform.support.aas.OperationsProvider
      • getSetter

        public java.util.function.Consumer<java.lang.Object> getSetter​(java.lang.String name)
        Specified by:
        getSetter in interface de.iip_ecosphere.platform.support.aas.OperationsProvider