Class InstanceToInstanceRegistry

All Implemented Interfaces:
ConfMgrRegistry, ADEPT2Service, AuthenticatingService, LogService, NameResolution, ServiceThreadHandling
Direct Known Subclasses:
LocalServiceRegistry, ModelFactoryRegistry

@ConfigurationDescription(properties=) public abstract class InstanceToInstanceRegistry extends PluginRegistry
This class extends the plugin registry to support the retrieval of used component instances without needing to know the used instance name at all. This name is set in the corresponding configuration. For instance, it can be configured, that the instance "PM1" of a process manager should use instance "DM1" of a DataManager. This is configured by: PM1.DataManager = DM1. "PM1" can retrieve the corresponding by calling getUsedObjectForInstance(session, "/ProcessManager/PM1", "DataManager", DataManager.class).
The used component type has to be managed by the registry.

The used component can be configured for all instances of the using type by configuring it: ProcessManager.LogManager = LM1. This configuration is used, in case no specific one for the using instance is found. If a usage relation is omitted, the default instance (see PluginRegistry) will be used.

This class parses the following properties from the registry configuration - besides the properties parsed by super classes:

  • Field Details

    • usedInstances

      protected final Map<String,Map<String,String>> usedInstances
      The usage relations for instances. It maps (hierarchical) usingInstanceName -> usedComponentType -> (hierarchical) usedInstanceName.
  • Constructor Details

    • InstanceToInstanceRegistry

      protected InstanceToInstanceRegistry(UrlConfigurationManager confMgr, Configuration configuration, Registry registry) throws ConfigurationException
      Constructs a new registry supporting instance to instance relations. It calls the constructor of PluginRegistry which sets the registry configuration, the configuration manager and the logger.
      Parameters:
      confMgr - The initial configuration manager that provides configurations for the loaded component instances.
      configuration - The configuration of the registry.
      registry - The parent registry of this registry.
      Throws:
      ConfigurationException - If the password cannot be parsed from the configuration, a ConfigurationException will be thrown.
  • Method Details

    • renewConfiguration

      protected void renewConfiguration(Configuration conf) throws ConfigurationException
      Renews the configuration of this registry by renewing via the superclass and reading of usage relations.
      Overrides:
      renewConfiguration in class PluginRegistry
      Parameters:
      conf - The (new) root configuration for this registry.
      Throws:
      ConfigurationException - If
      • mandatory properties are missing (PropertyNotSetException),
      • the class or interface of a type can not be found,
      • the instance is not configured properly (implementing class),
      a ConfigurationException will be thrown.
    • getUsedObjectForInstance

      protected <T> T getUsedObjectForInstance(String usingInstance, String usedComponentType, Class<T> requestedType) throws ConfigurationException
      Gets an object for use by the the designated component instance which conforms to the designated component type (usedComponentType) and is of the requested type. The instantiation mode of the used component is obeyed. If the instantiation mode is not set, singleton will be used.
      In case of a singleton instance, an existing object will be returned. For instantiating a new object, a constructor with the configuration ( Configuration) will be used.
      If the configuration does not contain a reference to an instance of the used component type, the appropriate anonymous instance will be returned.
      Type Parameters:
      T - The type which the requested object is expected to be of which is either the registered component type or a super type hereof.
      Parameters:
      usingInstance - The hierarchical name of the using component instance. Use the component type if the instance name is not defined. Use the empty string if the instance name is unknown.
      usedComponentType - The component type of the instance to be retrieved for usage. This may neither be null nor the empty string.
      requestedType - The type of which the requested object is expected to be. This is either the registered component type interface or a super type hereof.
      Returns:
      An object of the designated component type which is either the configured named instance or the appropriate anonymous instance.
      Throws:
      ConfigurationException - If
      • no component interface is registered/configured for the designated component type,
      • the usage relation or the used component type is not configured properly
      • the configured used instance is not declared or not configured properly,
      • the instantiation mode is set to off,
      • the configuration of the used instance does not provide required configuration values,
      • the creation or the initialisation of the instance fails,
      a ConfigurationException will be thrown.
      See Also:
    • getUsedComponentInstanceNameForInstance

      protected String getUsedComponentInstanceNameForInstance(String usingInstance, String usedComponentType) throws ConfigurationException
      Returns the hierarchical name of the instance of the designated type for usage by the designated instance (specified by its instance name). If no usage relation is found, the anonymous instance is returned for usage.
      Parameters:
      usingInstance - The hierarchical name of the component instance for which to retrieve the used component instance. Use the empty string if the instance name is not defined.
      usedComponentType - The component type to retrieve an instance name for. This may neither be null nor the empty string.
      Returns:
      The hierarchical name of the configured instance or the default instance of the used component type to be used by the designated using component instance.
      Throws:
      ConfigurationException - If there is no used component name found particularly even no default instance, a ConfigurationException will be thrown.