public class UrlConfigurationManager extends ConfigurationManager
JDBCDataSources cannot use a runtime configuration from a data source but
only from files.
Runtime configuration files have a default configuration directory that can be set via a
(system) property. If none is
specified, a subdirectory of the data directory will be used. The runtime configuration of a
specific component instance will be a file in this directory having the simple instance component
name as name. However, this file can be explicitly configured:
<InstanceName>.RuntimeConfiguration.File = <RelativePathOfRTConfigFile>
or
<InstanceName>.RuntimeConfiguration.File = <AbsolutePathOfRTConfigFile>.
The path may be relative to the runtime configuration directory or it may be absolute. It can
either be a file or a URL but it must be writable.
A runtime configuration from a database table needs a JDBCDataSource which needs to
be configured:
<InstanceName>.RuntimeConfiguration.JDBCDataSource = <SimpleNameOfJDBCDataSource>.
This class parses the following properties from a configuration:
ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_PREFIX,
ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_FILE)ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_PREFIX,
ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_FILE)ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_PREFIX,
ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_DATA_SOURCE)ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_PREFIX,
ConfigurationConstants.PROPERTY_CONFIGURATION_RUNTIME_DATA_SOURCE)ConfigurationConstants.CONFIG_CONFIGURATION_MANAGER,
ConfigurationConstants.CONFIGURATION_VARIABLE)| Modifier and Type | Field and Description |
|---|---|
protected NameResolution |
nameResolution
The resolution for service names.
|
protected java.lang.String |
rtConfDataSource
The simple name of the default JDBC data source used for configurations
that can be changed at runtime.
|
protected java.io.File |
runtimeConfigDir
The directory to store configurations that can be changed at runtime.
|
logger, providedConfiguration, REFERENCED_CONFIG_FILE_SUFFIX| Modifier | Constructor and Description |
|---|---|
protected |
UrlConfigurationManager(Configuration rootConfiguration,
Configuration providedConfiguration,
UrlConfigurationManager parent)
Creates a new
UrlConfigurationManager having the designated
root and provided configuration and the fields of the designated
UrlConfigurationManager. |
|
UrlConfigurationManager(java.lang.String rootConfFileName,
Configuration providedConfiguration,
boolean eager,
ConfigurationPropertyProvider provider,
LoggerManager loggerManager)
Creates a new
UrlConfigurationManager using the configuration
properties of the designated provider and either a root configuration
loaded from the designated file name, or the designated provided
configuration or a mixture of both respecting the order of the
configurations and configuration directories from the provider. |
| Modifier and Type | Method and Description |
|---|---|
UrlConfigurationManager |
createChild(java.lang.String instanceName,
java.lang.String componentType)
Creates a new configuration manager having all fields set to the same values as this
configuration manager.
|
protected Configuration |
getRtConfigDsFor(java.lang.String instanceName,
java.lang.String simpleDsName)
Gets the runtime configuration based on a data base table from the designated data source.
|
protected Configuration |
getRuntimeConfigDataSource(java.lang.String instanceName)
Gets the runtime configuration based on a data base table from a data source that is specified
for the designated instance in the root configuration.
|
protected java.lang.String |
getRuntimeConfigDataSourceConfigKey(java.lang.String instanceName)
Returns the configuration key to be looked up in the root configuration for retrieving the data
source instance name to be used for the runtime configuration of the service specified with the
given simple instance name.
|
protected java.lang.String |
getRuntimeConfigDataSourceName(java.lang.String instanceName)
Returns the simple instance name of the JDBCDataSource to be used for the runtime configuration
of the given service instance (simple) or null if none.
|
protected Configuration |
getRuntimeConfigFile(java.lang.String instanceName)
Gets the runtime configuration based on a file (or URL) specified for the designated instance
in the root configuration.
|
protected Configuration |
getRuntimeConfiguration(java.lang.String instanceName)
Gets a runtime configuration for the designated instance name which is a
Configuration-object that allows for storing the configuration values, for
instance as file or in a database. |
protected Configuration |
initRootConfiguration(java.lang.String rootConfFileName,
boolean eager,
ConfigurationPropertyProvider provider)
Loads the root configuration from the configuration directories, initialises the logging based
on this configuration and the logger manager of this configuration manager and dumps the
configuration if desired.
|
static DatabaseConfiguration |
newDatabaseConfiguration(java.util.logging.Logger logger,
JDBCDataSource dataSource,
java.lang.String tableName,
java.lang.String keyColumn,
java.lang.String valueColumn)
Creates a new
DatabaseConfiguration using the designated table and columns to
store the configuration in the designated data source. |
protected void |
setRegistry(LocalServiceRegistry registry,
SessionFactory sessionFactory,
java.net.URI[] uris)
Sets the registry, the session factory and the URIs to be used for
retrieving
JDBCDataSources for runtime configurations. |
cloneConfiguration, copyConfiguration, dumpConfiguration, getConfiguration, getConfiguration, getMergedRootConfiguration, getReferencedConfigurationFiles, getRootConfiguration, initConfiguration, loadAndDump, loadConfigurationFromFile, loadFromConfDir, loadFromConfDirs, loadReferencedConfigurations, loadToRootConfigurations, replaceVariables, setConfigurationDirectories, terminateprotected final NameResolution nameResolution
protected java.lang.String rtConfDataSource
null meaning that the global
directory should be used.protected final java.io.File runtimeConfigDir
global data source.public UrlConfigurationManager(java.lang.String rootConfFileName,
Configuration providedConfiguration,
boolean eager,
ConfigurationPropertyProvider provider,
LoggerManager loggerManager)
throws ConfigurationException
UrlConfigurationManager using the configuration
properties of the designated provider and either a root configuration
loaded from the designated file name, or the designated provided
configuration or a mixture of both respecting the order of the
configurations and configuration directories from the provider.rootConfFileName - The file name (relative to the configuration
directory/directories) of the root configuration for which to
create a UrlConfigurationManager. This may be
null but then a configuration has to be provided (
providedConfiguration).providedConfiguration - The configuration provided when bootstrapping.
This may either be a complete root configuration (without
additional configuration directories), a delta configuration
complementing or overriding the configurations from the
configuration directories or even null. If this is
null, only configurations from the configuration
directories will be used but this requires a valid
rootConfFileName.eager - Whether to (transitively) load all referenced configuration
files for the root configuration when initialising.provider - The provider for configuration properties.loggerManager - The logger manager providing and configuring the
loggers for the platform. Logging is initialised right after the
root configuration has been initialised.ConfigurationException - If
ConfigurationException will be thrown.protected UrlConfigurationManager(Configuration rootConfiguration, Configuration providedConfiguration, UrlConfigurationManager parent)
UrlConfigurationManager having the designated
root and provided configuration and the fields of the designated
UrlConfigurationManager.rootConfiguration - The root configuration to be used by the newly
created configuration manager. Usually this is a subset of the
root configuration of the designated
UrlConfigurationManager.providedConfiguration - The provided configuration to be used by the
newly created configuration manager. Usually this is a subset of
the provided configuration of the designated
UrlConfigurationManager.parent - The parent UrlConfigurationManager to retrieve
all further fields from.protected void setRegistry(LocalServiceRegistry registry, SessionFactory sessionFactory, java.net.URI[] uris)
JDBCDataSources for runtime configurations. Before
this method is called no runtime configurations from databases are
available. Early loaded components can only use files for runtime
configurations. registry - The registry to retrieve the JDBCDataSources
from.sessionFactory - The session factory to retrieve the
JDBCDataSources with.uris - The URIs for the session tokens to retrieve the
JDBCDataSources with.protected Configuration initRootConfiguration(java.lang.String rootConfFileName, boolean eager, ConfigurationPropertyProvider provider) throws ConfigurationException
If the default data source should be used for runtime configurations, this data source will be loaded.
initRootConfiguration in class ConfigurationManagerrootConfFileName - The name of the configuration file containing the root configuration.
This name is a relative path with file extension. If this is null, only
the provided configuration will be used.eager - Whether the root configuration should be loaded eagerly, that is all externally
referenced configuration files will be loaded.provider - The provider whether to debug log, that is, load the complete root
configuration and log it.ConfigurationException - If
ConfigurationException will be thrown.protected Configuration getRuntimeConfiguration(java.lang.String instanceName) throws ConfigurationException
Configuration-object that allows for storing the configuration values, for
instance as file or in a database. How the configuration is retrieved and where it is stored
depends on the implementing subclass.
Tries to load the runtime configuration from the configured data source, the configured file
name (or URL) or from the global runtime configuration directory. The first found runtime
configuration will be used. If no runtime configuration is found, null will be
returned.
getRuntimeConfiguration in class ConfigurationManagerinstanceName - The simple name of the component to get the runtime configuration for.Configuration-object allowing to store configuration values for the
designated instance.ConfigurationException - If a runtime configuration file is not a valid file or it can
not be written, a ConfigurationException will be thrown.ConfigurationException - If
ConfigurationException will be thrown.ConfigurationManager.getConfiguration(String)protected Configuration getRuntimeConfigFile(java.lang.String instanceName) throws ConfigurationException
null will be returned.instanceName - The simple name of the component to get the runtime configuration for.ConfigurationException - If
ConfigurationException will be thrown.protected Configuration getRuntimeConfigDataSource(java.lang.String instanceName) throws ConfigurationException
null will be returned.instanceName - The simple name of the component to get the runtime configuration for.ConfigurationException - If
ConfigurationException will be thrown.protected java.lang.String getRuntimeConfigDataSourceConfigKey(java.lang.String instanceName)
instanceName - The simple instance name of the service for which the configuration key
should be created.protected java.lang.String getRuntimeConfigDataSourceName(java.lang.String instanceName)
instanceName - The simple instance name of the service to find the runtime configuration
data source instance name for.protected Configuration getRtConfigDsFor(java.lang.String instanceName, java.lang.String simpleDsName) throws ConfigurationException
instanceName - The simple name of the component to get the runtime configuration for.simpleDsName - The simple name of the data source from which to retrieve the runtime
configuration.ConfigurationException - If
ConfigurationException will be thrown.public UrlConfigurationManager createChild(java.lang.String instanceName, java.lang.String componentType) throws ConfigurationException
ConfigurationManagernull the anonymous instance having the component type name
will be used. If the component type name is also null, the created configuration
manager will have the same root and provided configuration as this configuration manager.createChild in class ConfigurationManagerinstanceName - The simple name of the instance for which to retrieve the configuration. In
case of the anonymous instance this equals the component type name. Use
null for the bootstrap registry.componentType - The name of the component type to retrieve the configuration of the
designated instances. Use null for the bootstrap registry.ConfigurationException - If the configuration for the designated instance cannot be
retrieved, a ConfigurationException will be thrown.public static DatabaseConfiguration newDatabaseConfiguration(java.util.logging.Logger logger, JDBCDataSource dataSource, java.lang.String tableName, java.lang.String keyColumn, java.lang.String valueColumn) throws ConfigurationException, java.sql.SQLException
DatabaseConfiguration using the designated table and columns to
store the configuration in the designated data source. This also creates a table manager for
creating and deleting the table appropriately.logger - The logger for problems creating or dropping the table.dataSource - The datasource which stores the configuration.tableName - The name of the table containing the configuration values.keyColumn - The name of the column containing the configuration keys.valueColumn - The name of the column containing the configuration values.ConfigurationException - If creating the
configuration fails, a ConfigurationException will be thrown.java.sql.SQLException - If detecting whether the table exists or not fails, an
SQLException will be thrown.