Class AasPartRegistry

java.lang.Object
de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry

public class AasPartRegistry extends Object
A registry for AasContributor instances to be loaded via the Java Service loader.
Author:
Holger Eichelberger, SSE
See Also:
  • ExcludeFirst
  • Field Details

  • Constructor Details

    • AasPartRegistry

      public AasPartRegistry()
  • Method Details

    • ignoreAasUrlPaths

      private static boolean ignoreAasUrlPaths()
      Returns whether AAS URL paths shall be ignored.
      Returns:
      true for ignoring, false for considering
      See Also:
      • AasFactory.supportsUrlPaths()
    • createAasEndpointHolder

      private static EndpointHolder createAasEndpointHolder(de.iip_ecosphere.platform.support.Schema schema, String host, int port, String path)
      Creates an instance. Dependent on the AAS factory, may disable URL paths. [factory]
      Parameters:
      schema - the schema
      host - the host name
      port - the port
      path - the path denoting the endpoint
    • createAasEndpointHolder

      private static EndpointHolder createAasEndpointHolder(EndpointHolder holder)
      Creates an AAS endpoint holder. Dependent on the AAS factory, may disable URL paths. [factory]
      Parameters:
      holder - the holder to take the information from
      See Also:
    • getSubmodelIdentification

      public static String getSubmodelIdentification(String idShort)
      Returns the platform identification.
      Parameters:
      idShort - the idShort of the submodel
      Returns:
      the submodel identification, may be null usually leading to an identification through idShort
    • createSubmodelBuilder

      public static de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder createSubmodelBuilder(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, String idShort)
      Creates a submodel builder for the given aasBuilder and idShort deriving the submodel identification via getSubmodelIdentification(String).
      Parameters:
      aasBuilder - the "parent" AAS builder
      idShort - the idShort of the submodel
      Returns:
      the submodel builder
    • createSubmodelBuilder

      public static de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder createSubmodelBuilder(de.iip_ecosphere.platform.support.aas.Aas aas, String idShort)
      Creates a submodel builder for the given aas and idShort deriving the submodel identification via getSubmodelIdentification(String).
      Parameters:
      aas - the "parent" AAS
      idShort - the idShort of the submodel
      Returns:
      the submodel builder
    • createSubmodelBuilderRbac

      public static de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder createSubmodelBuilderRbac(de.iip_ecosphere.platform.support.aas.Aas.AasBuilder aasBuilder, String idShort)
      Creates a submodel builder for the given aasBuilder and idShort deriving the submodel identification via getSubmodelIdentification(String) with default authentication, i.e. applies RbacReceiver.rbacPlatform(AuthenticationDescriptor) with getSubmodelAuthentication().
      Parameters:
      aasBuilder - the "parent" AAS builder
      idShort - the idShort of the submodel
      Returns:
      the submodel builder
    • createSubmodelBuilderRbac

      public static de.iip_ecosphere.platform.support.aas.Submodel.SubmodelBuilder createSubmodelBuilderRbac(de.iip_ecosphere.platform.support.aas.Aas aas, String idShort)
      Creates a submodel builder for the given aas and idShort deriving the submodel identification via getSubmodelIdentification(String) with default authentication, i.e. applies RbacReceiver.rbacPlatform(AuthenticationDescriptor) with getSubmodelAuthentication().
      Parameters:
      aas - the "parent" AAS
      idShort - the idShort of the submodel
      Returns:
      the submodel builder
    • setAasSupplier

      public static void setAasSupplier(Supplier<List<de.iip_ecosphere.platform.support.aas.Aas>> supplier)
      Sets a supplier to provide instance to the real AAS server instance (rather than remote/connected instances via retrieveIipAas(). The real instance is e.g., needed to persist/store an AAS. Handle with care.
      Parameters:
      supplier - the supplier, may be null for none
    • getSetup

      public static AasPartRegistry.AasSetup getSetup()
      Returns the AAS setup.
      Returns:
      the setup
    • setAasSetup

      public static AasPartRegistry.AasSetup setAasSetup(AasPartRegistry.AasSetup aasSetup)
      Defines the AAS setup without resetting the AAS device/component implementation port.
      Parameters:
      aasSetup - the setup information
      Returns:
      the setup information before this call
      See Also:
    • setAasSetup

      public static AasPartRegistry.AasSetup setAasSetup(AasPartRegistry.AasSetup aasSetup, boolean resetImplPort)
      Defines the AAS setup.
      Parameters:
      aasSetup - the setup information
      resetImplPort - reset or keep the AAS device/component implementation port
      Returns:
      the setup information before this call
    • getContributorLoader

      private static ServiceLoader<AasContributor> getContributorLoader()
      Returns the contributor loader.
      Returns:
      the loader instance
    • contributors

      public static Iterator<AasContributor> contributors()
      Returns the contributors.
      Returns:
      the contributors
    • contributorClasses

      public static Set<Class<? extends AasContributor>> contributorClasses()
      Returns the contributor classes.
      Returns:
      the contributor classes
    • build

      public static AasPartRegistry.AasBuildResult build()
      Build up all AAS of the currently running platform part including all contributors. No implementation server is started. [public for testing]
      Returns:
      the list of AAS
    • build

      public static AasPartRegistry.AasBuildResult build(boolean startImplServer)
      Build up all AAS of the currently running platform part including all contributors. [public for testing]
      Parameters:
      startImplServer - whether the implementation server shall be started before creating the AAS, this may be required for incremental deployment
      Returns:
      the list of AAS
    • build

      Build up all AAS of the currently running platform part. No implementation server is started. [public for testing]
      Parameters:
      filter - filter out contributors, in particular for testing, e.g., active AAS that require an implementation server
      Returns:
      the list of AAS
    • build

      public static AasPartRegistry.AasBuildResult build(Predicate<AasContributor> filter, boolean startImplServer)
      Build up all AAS of the currently running platform part. [public for testing]
      Parameters:
      filter - filter out contributors, in particular for testing, e.g., active AAS that require an implementation server
      startImplServer - whether the implementation server shall be started before creating the AAS, this may be required for incremental deployment
      Returns:
      the list of AAS
    • build

      public static AasPartRegistry.AasBuildResult build(Predicate<AasContributor> filter, boolean startImplServer, de.iip_ecosphere.platform.support.aas.ProtocolServerBuilder sBuilder)
      Build up all AAS of the currently running platform part. [public for testing]
      Parameters:
      filter - filter out contributors, in particular for testing, e.g., active AAS that require an implementation server
      startImplServer - whether the implementation server shall be started before creating the AAS, this may be required for incremental deployment
      sBuilder - the protocol server builder. May be null then the method creates a new one, may be an instance that must then match the settings in AasPartRegistry.AasSetup.getImplementation().
      Returns:
      the list of AAS
    • retrieveIipAas

      public static de.iip_ecosphere.platform.support.aas.Aas retrieveIipAas() throws IOException
      Obtains the IIP-Ecosphere platform AAS. Be careful with the returned instance, as if the AAS is modified in the mean time, you may hold an outdated instance.
      Returns:
      the platform AAS (may be null for none)
      Throws:
      IOException - if the AAS cannot be read due to connection errors
    • retrieveAas

      public static de.iip_ecosphere.platform.support.aas.Aas retrieveAas(String identifier) throws IOException
      Obtains an AAS instance via the setup in this class. Be careful with the returned instance, as if the AAS is modified in the mean time, you may hold an outdated instance.
      Parameters:
      identifier - the identifier of the AAS (may be null or empty for an identification based on idShort, interpreted as an URN if this starts with urn)
      Returns:
      the platform AAS (may be null for none)
      Throws:
      IOException - if the AAS cannot be read due to connection errors
    • retrieveAas

      public static de.iip_ecosphere.platform.support.aas.Aas retrieveAas(AasPartRegistry.AasSetup setup, String identifier) throws IOException
      Obtains an AAS instance. Be careful with the returned instance, as if the AAS is modified in the mean time, you may hold an outdated instance. Populates the submodels initially with elements.
      Parameters:
      setup - the AAS setup
      identifier - the identifier of the AAS (may be null or empty for an identification based on idShort, interpreted as an URN if this starts with urn)
      Returns:
      the platform AAS (may be null for none)
      Throws:
      IOException - if the AAS cannot be read due to connection errors
    • retrieveAas

      public static de.iip_ecosphere.platform.support.aas.Aas retrieveAas(AasPartRegistry.AasSetup setup, String identifier, boolean populate) throws IOException
      Obtains an AAS instance. Be careful with the returned instance, as if the AAS is modified in the mean time, you may hold an outdated instance.
      Parameters:
      setup - the AAS setup
      identifier - the identifier of the AAS (may be null or empty for an identification based on idShort, interpreted as an URN if this starts with urn)
      populate - populates the submodels initially with elements (performance!)
      Returns:
      the platform AAS (may be null for none)
      Throws:
      IOException - if the AAS cannot be read due to connection errors
    • getIipAasInstance

      public static List<de.iip_ecosphere.platform.support.aas.Aas> getIipAasInstance()
      Returns the real AAS server instance based on the instances it was initially built. This instance is only available on server side and shall be used only in cases where a potentially remote/connected AAS (as it is typically returned by retrieveIipAas()) is not sufficient, e.g., for storing/persisting the AAS. It shall not be used for parallel accesses or for modifying the AAS.
      Returns:
      the AAS instance, may be null
    • deploy

      public static de.iip_ecosphere.platform.support.Server deploy(List<de.iip_ecosphere.platform.support.aas.Aas> aas, String... options)
      Deploy the given AAS to a local server. However, server and registry are created within the same tomcat instance and cannot be executed with different TLS settings.[testing]
      Parameters:
      aas - the list of aas, e.g., from build()
      options - optional server creation options
      Returns:
      the server instance
    • applyCorsOrigin

      public static <T extends de.iip_ecosphere.platform.support.aas.CorsEnabledRecipe> T applyCorsOrigin(T rcp, AasPartRegistry.AasSetup setup)
      Helper to apply the AasPartRegistry.AasSetup.getAccessControlAllowOrigin() from setup to rcp.
      Type Parameters:
      T - the receipt type
      Parameters:
      rcp - the recipe
      setup - the setup to take the information from
      Returns:
      the rcp
    • register

      public static de.iip_ecosphere.platform.support.Server register(List<de.iip_ecosphere.platform.support.aas.Aas> aas, de.iip_ecosphere.platform.support.Endpoint registry, String... options) throws IOException
      Registers the given AAS to a remote registry and creates a local server for the AAS.
      Parameters:
      aas - the list of aas, e.g., from build()
      registry - optional registry endpoint for remote registration, assuming a local in-memory registry if null
      options - optional server creation options
      Returns:
      the server instance
      Throws:
      IOException - if access to the AAS registry fails
    • remoteDeploy

      public static void remoteDeploy(List<de.iip_ecosphere.platform.support.aas.Aas> aas) throws IOException
      Performs a remote deployment of the given aas. Assumes that server and registry are up and running.
      Parameters:
      aas - the list of AAS, e.g., from build()
      Throws:
      IOException - if the deployment of an AAS fails or access to the AAS registry fails
    • remoteDeploy

      public static void remoteDeploy(AasPartRegistry.AasSetup setup, List<de.iip_ecosphere.platform.support.aas.Aas> aas) throws IOException
      Performs a remote deployment of the given aas. Assumes that server and registry are up and running.
      Parameters:
      setup - the AAS setup to use
      aas - the list of AAS, e.g., from build()
      Throws:
      IOException - if the deployment of an AAS fails or access to the AAS registry fails
    • getAas

      public static de.iip_ecosphere.platform.support.aas.Aas getAas(List<de.iip_ecosphere.platform.support.aas.Aas> list, String idShort)
      Returns the first AAS in list matching the given name. [utility]
      Parameters:
      list - the list to consider
      idShort - the short name to filter for
      Returns:
      the first AAS or null for none
    • getIipAasRegistry

      public static de.iip_ecosphere.platform.support.aas.Registry getIipAasRegistry()
      Returns the AAS registry for the endpoint in the setup of AasPartRegistry.
      Returns:
      the registry, may be null if there is none
    • addAasEndpointProperty

      private static de.iip_ecosphere.platform.support.aas.Property addAasEndpointProperty(de.iip_ecosphere.platform.support.aas.Registry reg, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder, String property, String aasId)
      Adds a property to builder pointing to an AAS endpoint for an AAS with id serviceId in registry reg.
      Parameters:
      reg - the registry, may be null then the property will have an empty value.
      builder - the builder to add the property to
      property - the shortId of the property to create
      aasId - the id of the AAS
      Returns:
      the created AAS property
    • addServiceAasEndpointProperty

      public static de.iip_ecosphere.platform.support.aas.Property addServiceAasEndpointProperty(de.iip_ecosphere.platform.support.aas.Registry reg, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder, String property, String serviceId)
      Adds a property to builder pointing to an AAS endpoint for a service with id serviceId in registry reg.
      Parameters:
      reg - the registry, may be null then the property will have an empty value.
      builder - the builder to add the property to
      property - the idShort of the property to create
      serviceId - the id of the service, may be empty leading to an empty property value
      Returns:
      the created AAS property
    • addDeviceAasEndpointProperty

      public static de.iip_ecosphere.platform.support.aas.Property addDeviceAasEndpointProperty(de.iip_ecosphere.platform.support.aas.Registry reg, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder, String property, String deviceId)
      Adds a property to builder pointing to an AAS endpoint for a device with id deviceId in registry reg.
      Parameters:
      reg - the registry, may be null then the property will have an empty value.
      builder - the builder to add the property to
      property - the idShort of the property to create
      deviceId - the id of the device, may be empty leading to an empty property value
      Returns:
      the created AAS property
    • getAasAuthentication

      public static de.iip_ecosphere.platform.support.aas.AuthenticationDescriptor getAasAuthentication()
      Returns the AAS authentication descriptor.
      Returns:
      the AAS authentication descriptor, may be null for none
      See Also:
    • getSubmodelAuthentication

      public static de.iip_ecosphere.platform.support.aas.AuthenticationDescriptor getSubmodelAuthentication()
      Returns the submodel authentication descriptor.
      Returns:
      the submodel authentication descriptor, may be null for none
      See Also:
    • composeIdentifier

      public static String composeIdentifier(String specificId)
      Composes an identifier based on URN_AAS and the given specific identifier.
      Parameters:
      specificId - the specific identifier
      Returns:
      the composed identifier
      See Also:
      • AasUtils.composeIdentifier(String, String)