Interface ConfigurableService

    • Field Detail

      • CONF_RUNTIME_CONF_PREFIX

        static final String CONF_RUNTIME_CONF_PREFIX
        A prefix for runtime configuration values that have defaults in the normal configuration to be overridden by the runtime configuration. The default and the runtime configuration values need to have different keys otherwise deleting a value will also delete the default value. The default value will reappear after the next reboot.
        See Also:
        Constant Field Values
    • Method Detail

      • getConfiguration

        org.apache.commons.configuration2.Configuration getConfiguration​(SessionToken session)
        Gets the configuration of this service for displaying it. It usually contains all configuration values of a service. Not all of them may be changed and not all of them by all users! Therefore filter the configuration appropriately based on the changeable keys. The returned configuration must not be changed directly since it usually is a copy of the configuration. Use setConfigurationValue(SessionToken, String, String) for changing configuration values.

        Note to implementors: As stated above return a copy of the configuration and not the configuration itself. Additionally make sure the returned configuration is serialisable since it may be transfered to a remote machine.

        Parameters:
        session - The session which is used to check for access rights on this method.
        Returns:
        The configuration of the service. Some of its values may be changed.
      • getConfigurationValue

        String getConfigurationValue​(SessionToken session,
                                     String key)
        Gets the string representation of the configuration value for the designated key or null if the key does not exist or has no value.
        Parameters:
        session - The session which is used to check for access rights on this method.
        key - The key of the configuration value.
        Returns:
        The string representation of the configuration value of the designated key or null if the key does not exist or has no value.
      • getChangeableConfigurationKeys

        List<String> getChangeableConfigurationKeys​(SessionToken session)
        Gets a list of configuration keys that may be changed by the owner of the designated session token. Note that these may contain keys that are not yet in the configuration.
        Parameters:
        session - The session which is used to check for access rights on this method and to determine which configuration keys can be changed by the designated user.
        Returns:
        A list of strings that represent the keys that may be changed by the user identified by the designated session token.
      • setConfigurationValue

        void setConfigurationValue​(SessionToken session,
                                   String key,
                                   String value)
                            throws ConfigurationException
        Sets the designated configuration value. Be sure to use a valid key. The keys are specified by the service. The value has to conform to the key, for instance, if the value is a list, the string has to reflect this appropriately. Use the empty string as value to delete the configuration.

        Note to implementors: Check the configuration value for validity and the session token for whether it is allowed to change the configuration.

        Parameters:
        session - The session which is used to check for access rights on this method.
        key - The key for the configuration value.
        value - The string representation of the configuration value to be set.
        Throws:
        ConfigurationException - If there are problems setting the designated value, for instance, the value does not conform to the designated key or is not a valid value at all, a ConfigurationException will be thrown.
      • copyConfiguration

        static SerialisableConfiguration copyConfiguration​(org.apache.commons.configuration2.Configuration conf,
                                                           int retries,
                                                           Logger logger)
        Creates a new serialisable configuration containing the values of the designated configuration. In case of concurrent modifications, reading of the complete configuration will be retried for the designated amount of retries. If they all fail, this will be logged and the incomplete copy will be returned.
        Parameters:
        conf - The configuration which to copy to a new configuration.
        retries - The amount of copying retries in case of a concurrent modification of the configuration value.
        logger - The logger in which to log that there have been to many concurrent modifications and that an incomplete configuration will be returned.
        Returns:
        A serialisable copy of the designated configuration containing the same values unless reading the configuration could not be completed several times due to concurrent modifications. In this case the returned configuration will be incomplete.