Class ConfigurationManagerImplBase

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static char GROUP_SEPARATOR
      Character that separates parameter name from group name in the parameter map.
      private java.util.Map<java.lang.String,​ConfigurationParameterDeclarations> mContextNameToParamDeclsMap
      Map from context name to ConfigurationParameterDeclarations for that context.
      protected java.util.Map<java.lang.String,​java.lang.String> mLinkMap
      Map the fully-qualified name of a parameter to the fully-qualified name of the parameter it is linked to (from which it takes its value).
      private Session mSession
      Current session.
      protected static java.lang.String SESSION_CONFIGURATION_KEY
      Key under which to store configuration information in the Session object.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String computeParentContextName​(java.lang.String aContextName)
      Get the name of the parent of the given context
      void createContext​(java.lang.String aContextName, ResourceMetaData aResourceMetaData, Settings externalOverrides)
      Creates and sets up a new configuration parameter context.
      protected void declareParameters​(java.lang.String aGroupName, ConfigurationParameter[] aParams, ConfigurationParameterSettings aSettings, java.lang.String aContextName, Settings aExternalOverrides)
      Called during creation of a new context.
      ConfigurationParameterDeclarations getConfigParameterDeclarations​(java.lang.String aContextName)
      Gets the ConfigurationParameterDeclarations for the given context.
      java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName)
      Retrieves the value for a configuration parameter.
      java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName, java.lang.String aGroupName)
      Retrieves the value for a configuration parameter in a group.
      private java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName, java.lang.String aGroupName, java.lang.String aSearchStrategy, java.lang.String aDefaultGroup)
      Utility method for getting a configuration parameter.
      ConfigurationParameterSettings getCurrentConfigParameterSettings​(java.lang.String aContextName)
      Gets an object containing the current settings for all configuration parameters within the given context.
      protected java.lang.String getLink​(java.lang.String aCompleteName)
      Gets the name of the parameter to which a given parameter is linked.
      protected java.lang.Class<?> getParameterExpectedValueClass​(ConfigurationParameter aParam)
      Get the Java class of the expected value of the specified parameter.
      private NameValuePair[] getParamSettings​(java.lang.String aGroupName, ConfigurationParameter[] aParams, java.lang.String aContextName)
      Utility method that gets a NameValuePair array containing the specific parameter settings.
      Session getSession()  
      private java.lang.Object getSessionParam​(java.lang.String aCompleteName)
      Gets a parameter value from the Session Parameter Map.
      protected java.lang.Object lookup​(java.lang.String aCompleteName)
      Does a direct lookup of a complete name, including the group.
      protected abstract java.lang.Object lookupSharedParamNoLinks​(java.lang.String aCompleteName)
      Looks up the value of a shared parameter, but does NOT follow links.
      protected java.lang.String makeQualifiedName​(java.lang.String aContextName, java.lang.String aParamName, java.lang.String aGroupName)
      Creates a qualified parameter name.
      void reconfigure​(java.lang.String aContextName)
      Completes the reconfiguration of parameters within the specified context.
      void setConfigParameterValue​(java.lang.String aQualifiedParamName, java.lang.Object aValue)
      Sets the value of a configuration parameter.
      void setConfigParameterValue​(java.lang.String aQualifiedParamName, java.lang.String aGroupName, java.lang.Object aValue)
      Sets the value of a configuration parameter in a group.
      void setSession​(Session aSession)
      Sets the current Session.
      private void setSessionParam​(java.lang.String aCompleteName, java.lang.Object aValue)
      Sets a parameter value in the Session Parameter Map.
      private void validateConfigurationParameterDataTypeMatch​(ConfigurationParameter aParam, java.lang.Object aValue, java.lang.String aContextName)
      Validate that a value is of an appropriate data type for assignment to the given parameter.
      private void validateConfigurationParameterSettings​(java.lang.String aContext)
      Validates configuration parameter settings.
      private void validateConfigurationParameterSettings​(java.lang.String aContext, ConfigurationParameter[] aParams, java.lang.String aGroupName)
      Validates configuration parameter settings within a group.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • GROUP_SEPARATOR

        protected static final char GROUP_SEPARATOR
        Character that separates parameter name from group name in the parameter map.
        See Also:
        Constant Field Values
      • SESSION_CONFIGURATION_KEY

        protected static final java.lang.String SESSION_CONFIGURATION_KEY
        Key under which to store configuration information in the Session object.
        See Also:
        Constant Field Values
      • mContextNameToParamDeclsMap

        private final java.util.Map<java.lang.String,​ConfigurationParameterDeclarations> mContextNameToParamDeclsMap
        Map from context name to ConfigurationParameterDeclarations for that context. Not sync'd based on belief: setup of values must be complete before any reference occurs, even in multi-threaded context. The setup is done under a sync'd control to insure only one setup is done, and to publish the updated results to other threads
      • mLinkMap

        protected final java.util.Map<java.lang.String,​java.lang.String> mLinkMap
        Map the fully-qualified name of a parameter to the fully-qualified name of the parameter it is linked to (from which it takes its value). Not sync'd based on belief: setup of values must be complete before any reference occurs, even in multi-threaded context. The setup is done under a sync'd control to insure only one setup is done
      • mSession

        private volatile Session mSession
        Current session. Used to store parameter settings done by the settings via API tae.setConfigParameterValue(...) can be set by multiple threads, but ought to be set to the same session object
    • Constructor Detail

      • ConfigurationManagerImplBase

        public ConfigurationManagerImplBase()
    • Method Detail

      • setSession

        public void setSession​(Session aSession)
        Description copied from interface: ConfigurationManager
        Sets the current Session. The Configuration Manager uses the Session object to store changes to configuration settings made by calling the setConfigParameterValue methods. This ensures that in a multi-client deployment those settings only apply to the same client that set them.

        Code that uses this class must be sure to call setSession before using the other methods (except createContext) on this class.

        Specified by:
        setSession in interface ConfigurationManager
        Parameters:
        aSession - the session object used to store configuration parameter overrides made by a particular client.
      • getSession

        public Session getSession()
      • createContext

        public void createContext​(java.lang.String aContextName,
                                  ResourceMetaData aResourceMetaData,
                                  Settings externalOverrides)
                           throws ResourceConfigurationException
        Description copied from interface: ConfigurationManager
        Creates and sets up a new configuration parameter context. This method is called during the initialization of each Resource that uses this Configuration Manager. Validation will be performed on the configuration parameters declared in this context; if an error is found an exception will be thrown. Multi-threading: This may be called with the same parameters on multiple threads. Implementations should check for repeated calls to create the same context and just return in that case
        Specified by:
        createContext in interface ConfigurationManager
        Parameters:
        aContextName - the name of the context in which the configuration parameter is being accessed. This corresponds to the path through the aggregate resource, e.g /subAE1/annotator1.
        aResourceMetaData - metadata object containing the configuration parameter declarations and settings.
        externalOverrides - the external overrides
        Throws:
        ResourceConfigurationException - if the configuration settings are invalid
      • getConfigParameterValue

        public java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName)
        Description copied from interface: ConfigurationManager
        Retrieves the value for a configuration parameter.
        Specified by:
        getConfigParameterValue in interface ConfigurationManager
        Parameters:
        aQualifiedParameterName - the fully-qualified configuration parameter name. This is of the form ContextName + / + ParameterName.
        Returns:
        the value of the parameter with the given name. The caller is expected to know the data type of the parameter. If the parameter does not exist,null is returned.
      • getConfigParameterValue

        public java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName,
                                                        java.lang.String aGroupName)
        Description copied from interface: ConfigurationManager
        Retrieves the value for a configuration parameter in a group.
        Specified by:
        getConfigParameterValue in interface ConfigurationManager
        Parameters:
        aQualifiedParameterName - the fully-qualified configuration parameter name. This is of the form ContextName + / + ParameterName.
        aGroupName - the name of the parameter group
        Returns:
        the value of the parameter with the given name. The caller is expected to know the data type of the parameter. If the parameter does not exist,null is returned.
      • setConfigParameterValue

        public void setConfigParameterValue​(java.lang.String aQualifiedParamName,
                                            java.lang.Object aValue)
        Description copied from interface: ConfigurationManager
        Sets the value of a configuration parameter. This only works for a parameter that is not defined in any group. Note that there is no guarantee that the change will take effect until ConfigurationManager.reconfigure(String) is called.
        Specified by:
        setConfigParameterValue in interface ConfigurationManager
        Parameters:
        aQualifiedParamName - the fully-qualified configuration parameter name. This is of the form ContextName + / + ParameterName.
        aValue - the value to assign to the parameter
      • setConfigParameterValue

        public void setConfigParameterValue​(java.lang.String aQualifiedParamName,
                                            java.lang.String aGroupName,
                                            java.lang.Object aValue)
        Description copied from interface: ConfigurationManager
        Sets the value of a configuration parameter in a group. Note that there is no guarantee that the change will take effect until ConfigurationManager.reconfigure(String) is called.
        Specified by:
        setConfigParameterValue in interface ConfigurationManager
        Parameters:
        aQualifiedParamName - the fully-qualified configuration parameter name. This is of the form ContextName + / + ParameterName.
        aGroupName - the name of a configuration group. If this parameter is null, this method will have the same effect as setParameterValue(String,Object).
        aValue - the value to assign to the parameter
      • getCurrentConfigParameterSettings

        public ConfigurationParameterSettings getCurrentConfigParameterSettings​(java.lang.String aContextName)
        Description copied from interface: ConfigurationManager
        Gets an object containing the current settings for all configuration parameters within the given context.
        Specified by:
        getCurrentConfigParameterSettings in interface ConfigurationManager
        Parameters:
        aContextName - name of context for which to retrieve parameter settings
        Returns:
        an object containing the current configuration parameter settings
      • lookup

        protected java.lang.Object lookup​(java.lang.String aCompleteName)
        Does a direct lookup of a complete name, including the group. Follows links but does not do any fallback processing. An external name definition overrides all
        Parameters:
        aCompleteName - complete name, of the form context/parameter$group
        Returns:
        value of parameter, null if none
      • declareParameters

        protected void declareParameters​(java.lang.String aGroupName,
                                         ConfigurationParameter[] aParams,
                                         ConfigurationParameterSettings aSettings,
                                         java.lang.String aContextName,
                                         Settings aExternalOverrides)
                                  throws ResourceConfigurationException
        Called during creation of a new context. Declares parameters, optionally in a group. Concrete subclasses will likely want to override this to set up any necessary data structures.
        Parameters:
        aGroupName - name of parameter group, null if none
        aParams - parameter declarations
        aSettings - settings for parameters
        aContextName - name of context containing this parameter
        aExternalOverrides - settings for parameters with external overrides
        Throws:
        ResourceConfigurationException - passthru
      • getLink

        protected java.lang.String getLink​(java.lang.String aCompleteName)
        Gets the name of the parameter to which a given parameter is linked.
        Parameters:
        aCompleteName - complete name, of the form context/parameter$group
        Returns:
        if the parameter with name aCompleteName is linked to another parameter, the complete name of that parameter is returned. Otherwise, null is returned.
      • lookupSharedParamNoLinks

        protected abstract java.lang.Object lookupSharedParamNoLinks​(java.lang.String aCompleteName)
        Looks up the value of a shared parameter, but does NOT follow links. Concrete subclasses must implement this to do the actual retrieval of configuration parameter values.
        Parameters:
        aCompleteName - complete name, of the form context/parameter$group
        Returns:
        value of parameter, or null if no value assigned
      • getParamSettings

        private NameValuePair[] getParamSettings​(java.lang.String aGroupName,
                                                 ConfigurationParameter[] aParams,
                                                 java.lang.String aContextName)
        Utility method that gets a NameValuePair array containing the specific parameter settings.
        Parameters:
        aGroupName - name of group containing params, may be null
        aParams - array of parameters to look up
        aContextName - context containing parameters
        Returns:
        array containing settings of the specific parameters
      • makeQualifiedName

        protected java.lang.String makeQualifiedName​(java.lang.String aContextName,
                                                     java.lang.String aParamName,
                                                     java.lang.String aGroupName)
        Creates a qualified parameter name. This consists of the context name followed by the param name (separate by a slash), followed by a $ character and the group name (if a group is specified).
        Parameters:
        aContextName - the name of the context containing this parameter
        aParamName - the configuration parameter name
        aGroupName - the name of the group containining the parameter, null if none
        Returns:
        the qualified parameter name
      • computeParentContextName

        private java.lang.String computeParentContextName​(java.lang.String aContextName)
        Get the name of the parent of the given context
        Parameters:
        aContextName - context name
        Returns:
        name of parent context
      • validateConfigurationParameterSettings

        private void validateConfigurationParameterSettings​(java.lang.String aContext)
                                                     throws ResourceConfigurationException
        Validates configuration parameter settings. This method checks to make sure that all required parameters have values and that the values are of the correct types.
        Throws:
        ResourceConfigurationException - if the configuration parameter settings are invalid
      • validateConfigurationParameterSettings

        private void validateConfigurationParameterSettings​(java.lang.String aContext,
                                                            ConfigurationParameter[] aParams,
                                                            java.lang.String aGroupName)
                                                     throws ResourceConfigurationException
        Validates configuration parameter settings within a group.
        Parameters:
        aContext - name of context containing the parameter settings
        aParams - parameter declarations
        aGroup - name of group to validate, null if none
        Throws:
        ResourceConfigurationException - if the configuration parameter settings are invalid
      • validateConfigurationParameterDataTypeMatch

        private void validateConfigurationParameterDataTypeMatch​(ConfigurationParameter aParam,
                                                                 java.lang.Object aValue,
                                                                 java.lang.String aContextName)
                                                          throws ResourceConfigurationException
        Validate that a value is of an appropriate data type for assignment to the given parameter.
        Parameters:
        aParam - configuration parameter
        aValue - candidate value
        aContextName - name of context, used to generate error message
        Throws:
        ResourceConfigurationException - if the data types do not match
      • getParameterExpectedValueClass

        protected java.lang.Class<?> getParameterExpectedValueClass​(ConfigurationParameter aParam)
        Get the Java class of the expected value of the specified parameter.
        Parameters:
        aParam - configuration parameter declaration information
        Returns:
        the expected value class
      • getConfigParameterValue

        private java.lang.Object getConfigParameterValue​(java.lang.String aQualifiedParameterName,
                                                         java.lang.String aGroupName,
                                                         java.lang.String aSearchStrategy,
                                                         java.lang.String aDefaultGroup)
        Utility method for getting a configuration parameter.
        Parameters:
        aGroupName - name of config group containing parameter
        aParamName - name of parameter
        aSearchStrategy - search strategy to use. Valid values are defined as constants on the ConfigurationParameterDeclarations interface.
        aDefaultGroup - default group to use, if search strategy requires it
        Returns:
        the value of the specified parameter, null if none
      • getSessionParam

        private java.lang.Object getSessionParam​(java.lang.String aCompleteName)
        Gets a parameter value from the Session Parameter Map.
        Parameters:
        aCompleteName - complete parameter name to look up
        Returns:
        a session-specific value for the given parameter, if any
        Throws:
        UIMA_IllegalStateException - if no Session has been set
      • setSessionParam

        private void setSessionParam​(java.lang.String aCompleteName,
                                     java.lang.Object aValue)
        Sets a parameter value in the Session Parameter Map.
        Parameters:
        aCompleteName - complete parameter name to look up
        aValue - value for the parameter
        Throws:
        UIMA_IllegalStateException - if no Session has been set