Class InstanceToInstanceRegistry

    • Field Detail

      • usedInstances

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

      • InstanceToInstanceRegistry

        protected InstanceToInstanceRegistry​(UrlConfigurationManager confMgr,
                                             org.apache.commons.configuration2.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 Detail

      • renewConfiguration

        protected void renewConfiguration​(org.apache.commons.configuration2.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:
        AbstractRegistry.getObjectForInstanceName(String, Class, Class[], Object[])
      • 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.