Class RegistryWrapper

java.lang.Object
de.aristaflow.adept2.base.registry.RegistryWrapper
All Implemented Interfaces:
NameResolution, Registry, ServiceAccess, ModelViewerProvider

public class RegistryWrapper extends Object implements Registry
A registry wrapper provides access to specific registry methods to a normal component/service. Besides a registry it also wraps the instance name of the component/service instance.
  • Field Details

    • clusterName

      protected final String clusterName
      The name of the cluster the component/service which uses this wrapper belongs to.
    • nodeName

      protected final String nodeName
      The unique name of the node this registry and the using service belong to.
    • release

      protected final SerialisablePair<String,String> release
      The release of the bootstrap registry.
    • hierInstName

      protected final String hierInstName
      The name of the component/service which uses this wrapper.
    • earlyService

      protected final boolean earlyService
      Whether the component/service using this wrapper is an early service for which initially only the local security manager is available.
    • registry

      protected final LocalServiceRegistry registry
      The registry to which the requests are forwarded.
    • modelFactoryRegistry

      protected final InstanceToInstanceRegistry modelFactoryRegistry
      The model factory registry for this wrapping registry.
    • modelViewerProvider

      protected final ModelViewerProvider modelViewerProvider
      The provider for retrieving model views.
  • Constructor Details

    • RegistryWrapper

      protected RegistryWrapper(String clusterName, String nodeName, SerialisablePair<String,String> release, String hierInstName, boolean earlyService, LocalServiceRegistry registry, InstanceToInstanceRegistry modelFactoryRegistry, ModelViewerProvider modelViewerProvider)
      Creates a new wrapper for wrapping a service registry and the name of a component/service instance.
      Parameters:
      clusterName - The name of the cluster the component/service which uses this wrapper belongs to.
      nodeName - The unique name of the node this registry and the using service belong to.
      release - The release of the bootstrap registry.
      hierInstName - The name of the component/service which uses this wrapper.
      earlyService - Whether the component/service is an early service for which initially only the local security manager is available.
      registry - The registry to which the requests are forwarded.
      modelFactoryRegistry - The model factory registry for this wrapping registry.
      modelViewerProvider - The provider for retrieving model views.
  • Method Details

    • getServiceOfType

      public <T extends ADEPT2Service> T getServiceOfType(SessionToken session, String serviceTypeName, Class<T> serviceType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Returns the service instance of the designated service type which is configured for usage by this (the requesting) service instance. If no special service instance is configured for usage, the default instance of the requested service type will be returned.
      Specified by:
      getServiceOfType in interface ServiceAccess
      Type Parameters:
      T - The type which the requested service is expected to be of. This is a subtype of ADEPT2Service and either the registered service type or a super type hereof.
      Parameters:
      session - The session which is used to check for access rights on this method.
      serviceTypeName - The type name of the requested service. Refer to ComponentTypes and BaseConstants for valid predefined service type names. Other service type names are also valid if the corresponding services are configured appropriately. ADEPT2Service and the interface configured for the service type or a super type hereof.
      serviceType - The type of the requested service. This is a subtype of ADEPT2Service and the interface configured for the service type or a super type hereof.
      Returns:
      The requested service (or a service stub). The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the service is not configured properly,
      • the service cannot be created or started,
      • a required service is not configured properly or cannot be started,
      • the creation of a required service object fails,
      • the service does not fulfil the ADEPT2Service -interface appropriately,
      • an exception is thrown while creating or starting a required service,
      a ServiceNotKnownException will be thrown. This may encapsulate a ConfigurationException or an AbortServiceException.
    • getModelFactory

      public <T> T getModelFactory(String modelFactoryName, Class<T> modelFactoryType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Gets the designated model factory registry.
      Specified by:
      getModelFactory in interface ServiceAccess
      Type Parameters:
      T - The type of the requested model factory registry.
      Parameters:
      modelFactoryName - The name of the requested model factory. Use the names declared in ModelRegistryConstants. No other model factory registries need to exist.
      modelFactoryType - The type of the requested model factory registry.
      Returns:
      The requested model factory registry. The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the requested model factory registry is not configured properly,
      • the requested model factory registry cannot be created,
      a ServiceNotKnownException wrapping a ConfigurationException will be thrown.
    • getModelViewerClass

      public Class<?> getModelViewerClass(String pluginID)
      Description copied from interface: ModelViewerProvider
      Gets the model viewer class for the designated plugin ID that allows type-save access to plugin data at model elements. If there is no model viewer configured for the designated plugin ID, null will be returned. This ID usually equals the ID of the (service-) plugin that uses the model viewer.
      Specified by:
      getModelViewerClass in interface ModelViewerProvider
      Parameters:
      pluginID - The ID of the plugin for which to retrieve a model viewer, this ID is usually the same ID as the one of the (service-) plugin using the plugin data.
      Returns:
      The model viewer class for the designated plugin ID or null in case there is no model viewer for the designated plugin ID configured.
    • getConfiguredPluginTypes

      public Map<String,Class<?>> getConfiguredPluginTypes(SessionToken session)
      Description copied from interface: ServiceAccess
      Retrieves all plugin types declared for the instance using this interface.
      Specified by:
      getConfiguredPluginTypes in interface ServiceAccess
      Parameters:
      session - The session which is used to check for access rights on this method.
      Returns:
      All plugin types (names and corresponding classes) declared for the instance using this interface. This map may be empty.
    • getConfiguredPlugin

      public <T> T getConfiguredPlugin(SessionToken session, Object usingInstance, String pluginTypeName, Class<T> componentType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Retrieves the default plugin of the designated type which is configured for the designated (using) instance. This is the same as ServiceAccess.getConfiguredPlugin(SessionToken, Object, String, Class, String) except that the default plugin instance is used, that is the first configured one. Therefore this will not be a runtime plugin.
      Specified by:
      getConfiguredPlugin in interface ServiceAccess
      Type Parameters:
      T - The type of the requested plugin.
      Parameters:
      session - The session which is used to check for access rights on this method.
      usingInstance - The instance which is using the plugin and which is provided in to the plugin when creating it. This allows the plugin to access the instance it extends.
      pluginTypeName - The component type of the plugin instance to be retrieved for usage. This may neither be null nor the empty string. The type name is specified in the configuration.
      componentType - The type of the requested plugin.
      Returns:
      The requested plugin instance. The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the plugin type is not configured for the designated object,
      • the plugin is not configured properly,
      • the creation or the initialisation of the plugin instance fails,
      a ServiceNotKnownException wrapping a ConfigurationException will be thrown.
    • getConfiguredPlugins

      public <T> Map<String,T> getConfiguredPlugins(SessionToken session, Object usingInstance, String pluginTypeName, Class<T> pluginType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Retrieves all plugin instances (pre-configured and dynamic) of the designated plugin type. A new plugin instance will be created if an instance is not singleton or it has not been instantiated before.
      Specified by:
      getConfiguredPlugins in interface ServiceAccess
      Type Parameters:
      T - The plugin type of the requested instances.
      Parameters:
      session - The session which is used to check for access rights on this method.
      usingInstance - The instance which is using the plugins and which is provided to the plugins when creating them. This allows the plugins to access the instance it extends.
      pluginTypeName - The component type of the plugin instance to be retrieved for usage. This may neither be null nor the empty string. The type name is specified in the configuration.
      pluginType - The type of the requested plugin.
      Returns:
      The requested plugin instances, indexed by their instance id. This map may be empty.
      Throws:
      ServiceNotKnownException - If
      • the plugin type is not configured for the designated object,
      • the configuration of a plugin instance does not provide required configuration values,
      • a plugin is not configured properly,
      • the creation or the initialisation of a plugin instance fails,
      a ServiceNotKnownException will be thrown.
    • getConfiguredPlugin

      public <T> T getConfiguredPlugin(SessionToken session, Object usingInstance, String pluginTypeName, Class<T> componentType, String pluginInstanceName) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Retrieves the plugin having the designated type and instance name as well as type and which is configured for the designated (using) instance. The designated using instance need to support plugins of the requested type. The plugin may be configured in the server/client configuration or it may be a runtime plugin that is found (together with its configuration) when requested. A new plugin instance will be created if the instance is not singleton or it has not been instantiated before.
      Specified by:
      getConfiguredPlugin in interface ServiceAccess
      Type Parameters:
      T - The type of the requested plugin.
      Parameters:
      session - The session which is used to check for access rights on this method.
      usingInstance - The instance which is using the plugin and which is provided in to the plugin when creating it. This allows the plugin to access the instance it extends.
      pluginTypeName - The component type of the plugin instance to be retrieved for usage. This may neither be null nor the empty string. The type name is specified in the configuration.
      componentType - The type of the requested plugin.
      pluginInstanceName - The simple name of the plugin instance to retrieve. This is either configured in the server/client configuration or in a configuration found at runtime.
      Returns:
      The requested plugin instance. The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the plugin type is not configured for the designated object,
      • the plugin is not configured properly,
      • the plugin is to be used as a runtime plugin but the designated object does not allow for runtime plugins,
      • the plugin is to be used as a runtime plugin but it is not found,
      • the creation or the initialisation of the plugin instance fails,
      a ServiceNotKnownException wrapping a ConfigurationException will be thrown.
    • getService

      public <T extends ADEPT2Service> T getService(SessionToken session, String serviceName, Class<T> serviceType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Returns the designated service which is either a local service or a service stub that is retrieved from the global registry if the service is not known to this registry but to the global registry.
      Specified by:
      getService in interface ServiceAccess
      Type Parameters:
      T - The type of the requested service. This is a subtype of ADEPT2Service and either interface configured for the service type or a super type hereof.
      Parameters:
      session - The session which is used to check for access rights on this method.
      serviceName - The hierarchical instance name of the service.
      serviceType - The type of the requested service. This is a subtype of ADEPT2Service and the interface configured for the service type or a super type hereof.
      Returns:
      The requested service (or a service stub). The object is never null.
      Throws:
      ServiceNotKnownException - If
      • the service is not configured properly,
      • the service cannot be created or started,
      • a required service is not configured properly or cannot be started,
      • the creation of a required service object fails,
      • the service does not fulfill the ADEPT2Service -interface appropriately,
      • an exception is thrown while creating or starting a required service,
      a ServiceNotKnownException will be thrown. This may encapsulate a ConfigurationException or an AbortServiceException.
    • getService

      public <T extends ADEPT2Service> T getService(SessionToken session, URI[] serviceURIs, Class<T> serviceType) throws ServiceNotKnownException
      Description copied from interface: ServiceAccess
      Retrieves the service described by the URIs which is either a local service stub that is retrieved from the global registry if the service is not known to this registry but to the global registry. An appropriate URI will be chosen, that is, a URI with a protocol supported by this registry.
      Specified by:
      getService in interface ServiceAccess
      Type Parameters:
      T - The type of the requested service. This is a subtype of ADEPT2Service and either interface configured for the service type or a super type hereof.
      Parameters:
      session - The session which is used to check for access rights on this method.
      serviceURIs - The URIs of the service to be retrieved, the array has to contain at least one valid service URI.
      serviceType - The type of the requested service. This is a subtype of ADEPT2Service and the interface configured for the service type or a super type hereof.
      Returns:
      The requested service (or a service stub). The object is never null.
      Throws:
      ServiceNotKnownException - If
      • no appropriate communication service is available for the designated URIs,
      • the service is not configured properly,
      • the service cannot be created or started,
      • a required service is not configured properly or cannot be started,
      • the creation of a required service object fails,
      • the service does not fulfill the ADEPT2Service -interface appropriately,
      • an exception is thrown while creating or starting a required service,
      a ServiceNotKnownException will be thrown. This may encapsulate a ConfigurationException or an AbortServiceException.
    • getSecurityManager

      public SecurityManager getSecurityManager()
      Description copied from interface: Registry
      Gets the security manager of the system. This allows for authenticating users.
      Specified by:
      getSecurityManager in interface Registry
      Returns:
      The security manager of the system for authenticating users.
    • isEarlyService

      public boolean isEarlyService()
      Description copied from interface: Registry
      Gets whether the service using this registry is an early service and thus uses the local security manager first. This means, that the service will have to re-authenticate after the global security manager has been set which in turn means changing the session factory while running.
      Specified by:
      isEarlyService in interface Registry
      Returns:
      Whether the service using this registry is an early service and thus uses the local security manager first.
    • getClusterName

      public String getClusterName()
      Description copied from interface: Registry
      Gets the name of the cluster this registry and the using service belong to. Use this name for identification purpose across clusters.
      Specified by:
      getClusterName in interface Registry
      Returns:
      The name of the cluster this registry and the using service belong to.
    • getUniqueNodeName

      public String getUniqueNodeName()
      Description copied from interface: Registry
      Gets the unique name of the node this registry and the using service belong to. Use this name for identification across started platforms.
      Specified by:
      getUniqueNodeName in interface Registry
      Returns:
      The unique name of the node this registry and the using service belong to.
    • getRelease

      public SerialisablePair<String,String> getRelease()
      Description copied from interface: Registry
      Gets the release of the bootstrap registry, that is, the build version and the build date.
      Specified by:
      getRelease in interface Registry
      Returns:
      The build version and the build date of the bootstrap registry.
    • getInstanceName

      public String getInstanceName()
      Description copied from interface: Registry
      Gets the hierarchical instance name of the service using this registry. Do not use this name for accessing the registry. If you need to do this, you are doing something wrong. Use this name for identification purpose like logging of the service.
      Specified by:
      getInstanceName in interface Registry
      Returns:
      The hierarchical instance name of the service using this registry for identification purpose like logging.
    • getGlobalSequence

      public AtomicLong getGlobalSequence(String seqName)
      Description copied from interface: Registry
      Gets the sequence of the designated name. This sequence is platform-wide (i. e. bound to the running BPM platform/JVM) and may be shared among several service instances and even service types.
      Specified by:
      getGlobalSequence in interface Registry
      Parameters:
      seqName - The name of the platform-wide sequence. This name is arbitrary but should be shared among the services that share the sequence.
      Returns:
      An atomic long representing the designated sequence.
    • registryActive

      public boolean registryActive()
      Description copied from interface: Registry
      Gets whether the underlying registry is active, that is, it has signalled its start and is not being shut down.
      Specified by:
      registryActive in interface Registry
      Returns:
      Whether the underlying registry is active, that is, it has signalled its start and is not being shut down.
    • getHierarchicalInstanceName

      public String getHierarchicalInstanceName(String componentType, String simpleName)
      Description copied from interface: NameResolution
      Returns a hierarchical instance name containing the component type as well as the instance name. The returned string resembles, for instance, /ProcessManager/PM1.
      Specified by:
      getHierarchicalInstanceName in interface NameResolution
      Parameters:
      componentType - The type of the component to create the hierarchical name for.
      simpleName - The simple name of the component instance as defined in the configuration.
      Returns:
      An instance name containing the component type and the simple component instance name.
    • getSimpleInstanceName

      public String getSimpleInstanceName(String instName)
      Description copied from interface: NameResolution
      Returns the simple name of the designated component instance as used in configuration files.
      Specified by:
      getSimpleInstanceName in interface NameResolution
      Parameters:
      instName - The hierarchical name of a component instance.
      Returns:
      The simple name without the prepending type of the component instance.
    • getComponentType

      public String getComponentType(String instName)
      Description copied from interface: NameResolution
      Returns the name of the component type of the designated component instance as used in configuration files.
      Specified by:
      getComponentType in interface NameResolution
      Parameters:
      instName - The hierarchical name of a component instance.
      Returns:
      The name of the component type.
    • getNames

      public Pair<String,String> getNames(String instName)
      Description copied from interface: NameResolution
      Gets the component type name and the simple instance name of the designated component instance at once.
      Specified by:
      getNames in interface NameResolution
      Parameters:
      instName - The hierarchical name of a component instance.
      Returns:
      The name of the component type and the simple name of the designated component instance.
    • getFormattedSignature

      public String getFormattedSignature(Class<?>[] parameterTypes)
      Description copied from interface: NameResolution
      Helper method for getting a string describing the parameter types as method signature for use in log messages and exceptions.
      Specified by:
      getFormattedSignature in interface NameResolution
      Parameters:
      parameterTypes - All the parameter types of a method as instances of Class.
      Returns:
      A string describing the parameter types as method signature (concatenated and surrounded by parenthesis).
    • getInterfaceForComponentType

      public Class<?> getInterfaceForComponentType(String componentType) throws ConfigurationException
      Description copied from interface: ServiceAccess
      Returns the class object of the corresponding interface / superclass, if the component type is declared. If not, the method throws a ConfigurationException. This method must not to be called by clients; it is only for the registry and the communication framework.
      Specified by:
      getInterfaceForComponentType in interface ServiceAccess
      Parameters:
      componentType - The name of the component type of which to retrieve the configured interface.
      Returns:
      The class object of the corresponding interface / superclass.
      Throws:
      ConfigurationException - If the designated component type is not configured for this registry, a ConfigurationException will be thrown.