Interface IRepositoryConfigService
The loading process is depended from a type of configuration and hierarchy and inheritance settings. Configurations are stored and retrieved in a context, or for a user.
If configuration is hierarchy but not inherited the service will try to find first configuration file from a context to a root. If configuration is hierarchy and inherited the service will try to find all configuration files from a context to a root. If configuration isn't hierarchy (and so automatically isn't inherited) the service will try to load file only from context.
The configuration may be global and specific (defined by prefix). Now if prefix specified the service tries to find specific configuration (according the rules above) and only if nothing found switch to a global.
The prefix parameter always attached to a file name (even if file is specified
with path) by a '-' character, e.g. if prefix if pref
and file
name is .set/subs/cooler.xml
the file name for specific configuration
will be .set/subs/pref-cooler.xml
- Author:
- POLARION SOFTWARE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfigurationListener
(String configId, String prefix, IContextId contextId, IConfigListener l) Registers the listener, which will be notified after change in configuration occurs.void
addUserConfigurationListener
(String configId, String userId, IUserConfigListener l) Registers the listener, which will be notified after change in configuration occurs.void
defineConfiguration
(String configId, boolean hierarchic, boolean inheritable, String cfgFilePath, IDataHandler<?, ?> dataHandler) Defines the configuration programmatically - this is an alternative to definition by deployment.void
defineUserConfiguration
(String configId, boolean inheritable, String cfgFilePath, String defaultCfgFilePath, IDataHandler<?, ?> dataHandler) Defines the configuration programmatically - this is an alternative to definition by deployment.void
void
executeInDataHandlerResultsCachingContext
(Object[] locationsCacheRef, RunnableWEx r) boolean
existsAnyConfiguration
(String configId, String prefix, IContextId contextId) Whether the configuration exists exactly in the specified context and with the specified prefix, or it exists in another context or without the prefix according to hierarchy and inheritance settings.boolean
existsSpecificConfiguration
(String configId, String prefix, IContextId contextId) Whether the configuration exists exactly in the specified context and with the specified prefix (no hierarchy or inheritance processing).Returns problem catcher.getConfigurationForUpdate
(String configId, IContextId contextId) This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadConfiguration(String, IContextId)
instead.getConfigurationForUpdate
(String configId, String prefix, IContextId contextId) This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadConfiguration(String, String, IContextId)
instead.getConfigurationLocationForUpload
(String configId, IContextId contextId) This method is intended only for configuration file uploading clients.getConfigurationLocationForUpload
(String configId, String prefix, IContextId contextId) This method is intended only for configuration file uploading clients.getExistingPrefixes
(String configId, IContextId contextId) This method returns the existing prefixes for given configuration.getReadConfiguration
(String configId, IContextId context) Returns the global read-only configuration for direct usage.getReadConfiguration
(String configId, String prefix, IContextId contextId) Returns the specific read-only configuration for direct usage.getReadUserConfiguration
(String configId, String userId) Returns user specific configuration that can be used directly.getUserConfigurationForUpdate
(String configId, String userId) This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadUserConfiguration(String, String)
instead.getUserConfigurationLocationForUpload
(String configId, String userId) This method is intended only for configuration file uploading clients.void
Invalidates configuration cachevoid
boolean
isConfigurationDefined
(String configId) void
removeConfigurationListener
(String configId, String prefix, IContextId contextId, IConfigListener l) Removes already registered listener.void
removeUserConfigurationListener
(String configId, String userId, IUserConfigListener l) Removes already registered listener.void
saveConfiguration
(String configId, IContextId contextId, Object config) Saves the global configuration.void
saveConfiguration
(String configId, String prefix, IContextId contextId, Object config) Saves the specific configuration.void
saveUserConfiguration
(String configId, String userId, Object config) Saves user specific configuration.validateConfiguration
(String configId, String prefix, IContextId contextId, Object config) Validates the specific configuration.
-
Method Details
-
getReadConfiguration
Returns the global read-only configuration for direct usage. This configuration is processed with respect to hierarchy and inheritance settings.It should NEVER be used as input for
saveConfiguration(String, IContextId, Object)
.Same as
getReadConfiguration(configId, null, context)
- Parameters:
configId
-context
-- Returns:
- The IConfig object (never
null
). - Throws:
IllegalArgumentException
- If the configId is not defined.
-
getReadConfiguration
IConfig getReadConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId) Returns the specific read-only configuration for direct usage. The typed configuration is processed with respect to hierarchy and inheritance settings.This method start to scan all prefix configuration from given context to the root and then scan global (with out prefix) configuration from given context to the root
It should NEVER be used as input for
saveConfiguration(String, IContextId, Object)
.- Parameters:
configId
-prefix
-contextId
-- Returns:
- The IConfig object (Never returns null, but data can be
null
). - Throws:
IllegalArgumentException
- If the configId is not defined.
-
existsAnyConfiguration
boolean existsAnyConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId) Whether the configuration exists exactly in the specified context and with the specified prefix, or it exists in another context or without the prefix according to hierarchy and inheritance settings.- Since:
- 3.23.4
- See Also:
-
existsSpecificConfiguration
boolean existsSpecificConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId) Whether the configuration exists exactly in the specified context and with the specified prefix (no hierarchy or inheritance processing).- Since:
- 3.23.4
- See Also:
-
getReadUserConfiguration
Returns user specific configuration that can be used directly. It should NEVER be used as input forsaveUserConfiguration(String, String, Object)
.- Parameters:
configId
-userId
- user id ornull
for the default configuration- Returns:
- The IConfig object (Never returns null, but data can be
null
).
-
addConfigurationListener
void addConfigurationListener(String configId, String prefix, IContextId contextId, IConfigListener l) Registers the listener, which will be notified after change in configuration occurs. The listener gets notified only on permanent changes, not on in-transaction (uncommitted) ones.The same instance of the listener might be registered for different config parameters.
- Parameters:
configId
-prefix
-contextId
-l
-
-
addUserConfigurationListener
Registers the listener, which will be notified after change in configuration occurs. The listener gets notified only on permanent changes, not on in-transaction (uncommitted) ones.The same instance of the listener might be registered for different config parameters.
- Parameters:
configId
-userId
- user id ornull
for the default configurationl
-
-
removeConfigurationListener
void removeConfigurationListener(String configId, String prefix, IContextId contextId, IConfigListener l) Removes already registered listener. Nothing happens if the listener is not registered.- Parameters:
configId
-prefix
-contextId
-l
-
-
removeUserConfigurationListener
Removes already registered listener. Nothing happens if the listener is not registered.- Parameters:
configId
-userId
- user id ornull
for the default configurationl
-
-
getConfigurationForUpdate
This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadConfiguration(String, IContextId)
instead.Same as
getConfigurationForUpdate(configId, null, context)
- Parameters:
configId
-contextId
-- Returns:
- The configuration object corresponding to the given context,
NO hierarchy/inheritance searches/merges are done. Returns
null
if the given context has no configuration (even if it's parent configs have some).
-
getConfigurationForUpdate
This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadConfiguration(String, String, IContextId)
instead.- Parameters:
configId
-prefix
-contextId
-- Returns:
- The configuration object corresponding to the given context,
NO hierarchy/inheritance searches/merges are done. Returns
null
if the given context has no configuration (even if it's parent configs have some).
-
getUserConfigurationForUpdate
This method is intended for configuration-editing clients, NOT for configuration-using clients (these should usegetReadUserConfiguration(String, String)
instead.- Parameters:
configId
-userId
- user id ornull
for the default configuration- Returns:
- The configuration object corresponding to the given context,
NO inheritance searches/merges are done. Returns
null
if the given context has no configuration (even if it's parent configs have some).
-
getConfigurationLocationForUpload
This method is intended only for configuration file uploading clients.- Parameters:
configId
-contextId
-- Returns:
- the location of the configuration file.
-
getConfigurationLocationForUpload
This method is intended only for configuration file uploading clients.- Parameters:
configId
-prefix
-contextId
-- Returns:
- the location of the configuration file.
-
getUserConfigurationLocationForUpload
This method is intended only for configuration file uploading clients.- Parameters:
configId
-userId
- user id ornull
for the default configuration- Returns:
- the location of the configuration file.
-
saveConfiguration
Saves the global configuration. Saves the configuration.Same as
saveConfiguration(configId, null, context, config)
- Parameters:
configId
-contextId
-config
-
-
saveConfiguration
void saveConfiguration(@NotNull String configId, @Nullable String prefix, @NotNull IContextId contextId, @Nullable Object config) Saves the specific configuration.- Parameters:
configId
-prefix
-contextId
-config
- The configuration to save. It's conversion to stream is handled by theIDataHandler
. If theconfig
isnull
, then the existing configuration is deleted.
-
saveUserConfiguration
Saves user specific configuration.- Parameters:
configId
-userId
- user id ornull
for the default configurationconfig
- The configuration to save. It's conversion to stream is handled by theIDataHandler
. If theconfig
isnull
, then the existing configuration is deleted.
-
getExistingPrefixes
This method returns the existing prefixes for given configuration.Note, that this will return only prefixes, which could affect the results for the current context. Therefore
- For non-hierarchical config only the current context is searched.
- For hierarchy the search will stop in context, which contains the generic (prefix-less) configuration
- For inheritable config, all parent contexts will be processed
The collection of prefixes is wrapped in
IConfig
, so that client can cache results build on top of the prefixes.The
null
prefix is never included in the collection.- Parameters:
configId
-contextId
-- Returns:
IConfig
with dataCollection
of String prefixes.
-
validateConfiguration
Validates the specific configuration.- Parameters:
configId
-prefix
-contextId
-config
- The configuration to validate. It's conversion to stream is handled by theIDataHandler
.- Since:
- 3.6.2
-
defineConfiguration
void defineConfiguration(String configId, boolean hierarchic, boolean inheritable, String cfgFilePath, IDataHandler<?, ?> dataHandler) Defines the configuration programmatically - this is an alternative to definition by deployment.The meaning of parameters is the same as in deployment.
Once a configuration is defined, it can never be removed during runtime.
- Parameters:
configId
- The configuration ID, might not benull
.hierarchic
- Iftrue
then config will be looked in parent contexts if will be absent in the specific one.inheritable
- Can betrue
only ifhierarchic == true
as well. Iftrue
then all configurations from given context up to the root will be taken into account and merged for the final result.cfgFilePath
- Path to the config file. Must not benull
.dataHandler
- Data handler, ifnull
, then the default one is used (DOMDataHandler
).- Throws:
IllegalArgumentException
- if configuration with such ID is already defined.
-
defineUserConfiguration
void defineUserConfiguration(String configId, boolean inheritable, String cfgFilePath, String defaultCfgFilePath, IDataHandler<?, ?> dataHandler) Defines the configuration programmatically - this is an alternative to definition by deployment.The meaning of parameters is the same as in deployment.
Once a configuration is defined, it can never be removed during runtime.
- Parameters:
configId
- The configuration ID, might not benull
.inheritable
-cfgFilePath
- Path to the config file. Must not benull
.defaultCfgFilePath
- Path to the default config file ornull
.dataHandler
- Data handler, ifnull
, then the default one is used (DOMDataHandler
).- Throws:
IllegalArgumentException
- if configuration with such ID is already defined.
-
isConfigurationDefined
- Parameters:
configId
-- Returns:
true
if the configuration with given ID is defined, false otherwise.
-
getConfigProblemCatcher
IConfigProblemCatcher getConfigProblemCatcher()Returns problem catcher.- Returns:
- problem catcher (not
null
) - Since:
- 3.1.2
-
executeInDataHandlerResultsCachingContext
- Since:
- 3.2.1
-
executeInDataHandlerResultsCachingContext
void executeInDataHandlerResultsCachingContext(@NotNull Object[] locationsCacheRef, @NotNull RunnableWEx r) - Since:
- 3.4.3
-
invalidateLocation
- Since:
- 3.5.0
-
invalidateAll
void invalidateAll()Invalidates configuration cache- Since:
- 3.17.0
-