Class ServiceFactory

java.lang.Object
de.iip_ecosphere.platform.services.ServiceFactory

public class ServiceFactory extends Object
Provides access to the service manager instance.
Author:
Holger Eichelberger, SSE
  • Field Details

    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
    • desc

      private static ServiceFactoryDescriptor desc
    • manager

      private static ServiceManager manager
    • service

      private static ServiceSetup service
    • setup

      private static de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup setup
    • transport

      private static de.iip_ecosphere.platform.transport.connectors.TransportSetup transport
    • netwMgrSetup

      private static de.iip_ecosphere.platform.support.net.NetworkManagerSetup netwMgrSetup
    • yamlPath

      private static String yamlPath
  • Constructor Details

    • ServiceFactory

      public ServiceFactory()
  • Method Details

    • setYamlPath

      public static void setYamlPath(String path)
      Sets the YAML path if setup YAML must be read from a nested object. Shall be maintained by implementing class or tests. [testing]
      Parameters:
      path - the path, by default none/null
    • init

      private static void init()
      Initializes this factory.
    • getServiceManager

      public static ServiceManager getServiceManager()
      Returns the service manager.
      Returns:
      the service manager
    • getSetupClass

      public static Class<? extends ServiceSetup> getSetupClass()
      Returns the service setup class.
      Returns:
      the service setup class, either from the descriptor or ServiceSetup
    • getSetup

      public static ServiceSetup getSetup()
      Returns the actual service setup for the implementing service manager.
      Returns:
      the service setup
    • getAasSetup

      public static de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup getAasSetup()
      Returns the actual AAS setup for the implementing service manager.
      Returns:
      the AAS setup
    • getNetworkManagerSetup

      public static de.iip_ecosphere.platform.support.net.NetworkManagerSetup getNetworkManagerSetup()
      Returns the actual network manager setup.
      Returns:
      the network manager setup
    • getTransport

      public static de.iip_ecosphere.platform.transport.connectors.TransportSetup getTransport()
      Returns the actual transport setup for the implementing service manager.
      Returns:
      the AAS setup
    • getFromSetup

      private static <T> T getFromSetup(T object, Function<ServiceFactoryDescriptor,T> fromDesc, Function<ServiceSetup,T> fromSetup, Supplier<T> constructor, Consumer<T> setter)
      Returns an object from setup. If not anyway present, calls #init(), then first tries to get the object from the descriptor via fromDesc, then by directly loading the setup via getSetupClass() and yamlPath, and finally via constructor.
      Type Parameters:
      T - the type of object to read
      Parameters:
      object - the actual value, returned if not null
      fromDesc - the projection from the descriptor
      fromSetup - the projection from a freshly read setup as first fallback
      constructor - the constructor as second fallback
      setter - if a new object is obtained, store it for future use
      Returns:
      the object or if null from descriptor, setup or constructor
    • setAasSetup

      public static void setAasSetup(de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup instance)
      Defines the AAS setup instance.
      Parameters:
      instance - the new setup instance
    • setNetworkManagerSetup

      public static void setNetworkManagerSetup(de.iip_ecosphere.platform.support.net.NetworkManagerSetup instance)
      Defines the network manager setup instance.
      Parameters:
      instance - the new setup instance
    • getTests

      public static Class<?>[] getTests(int index)
      Returns a test represented as it's class for execution in jUnit. This is required if a test running a service manager and other components like AAS as plugins shall get execute a test independently. Delegates the work to ServiceFactoryDescriptor. [testing]
      Parameters:
      index - a 0-based index of the test/suite to return; usually test and implementing service manager are in close relationship and know the valid indexes
      Returns:
      the test classes or null if there is none for the given index