@Service(value="archivaConfiguration#default") public class DefaultArchivaConfiguration extends Object implements ArchivaConfiguration, org.apache.archiva.components.registry.RegistryListener
Implementation of configuration holder that retrieves it from the registry.
The registry layers and merges the 2 configuration files: user, and application server.
Instead of relying on the model defaults, if the registry is empty a default configuration file is loaded and applied from a resource. The defaults are not loaded into the registry as the lists (eg repositories) could no longer be removed if that was the case.
When saving the configuration, it is saved to the location it was read from. If it was read from the defaults, it will be saved to the user location. However, if the configuration contains information from both sources, an exception is raised as this is currently unsupported. The reason for this is that it is not possible to identify where to re-save elements, and can result in list configurations (eg repositories) becoming inconsistent.
If the configuration is outdated, it will be upgraded when it is loaded. This is done by checking the version flag before reading it from the registry.
FIXME: The synchronization must be improved, the current impl may lead to inconsistent data or multiple getConfiguration() calls (martin_s@apache.org)
USER_CONFIG_ENVVAR, USER_CONFIG_PROPERTY
Constructor and Description |
---|
DefaultArchivaConfiguration() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(org.apache.archiva.components.registry.RegistryListener listener)
Add a registry listener to notify of events in spring-registry.
|
void |
addListener(ConfigurationListener listener)
Add a configuration listener to notify of changes to the configuration.
|
void |
afterConfigurationChange(org.apache.archiva.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
void |
beforeConfigurationChange(org.apache.archiva.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
String |
getAltConfigFilename() |
Path |
getAppServerBaseDir() |
Configuration |
getConfiguration()
Get the configuration.
|
Path |
getDataDirectory()
Returns the data directory where repositories and metadata reside
|
Locale |
getDefaultLocale() |
List<Locale.LanguageRange> |
getLanguagePriorities() |
org.apache.archiva.components.registry.Registry |
getRegistry() |
Path |
getRemoteRepositoryBaseDir()
Returns the base directory for remote repositories
|
Path |
getRepositoryBaseDir()
Returns the base directory for repositories that have a relative location path set.
|
Path |
getRepositoryGroupBaseDir()
Returns the base directory for repository group files.
|
String |
getUserConfigFilename() |
void |
initialize() |
boolean |
isDefaulted()
Determines if the configuration in use was as a result of a defaulted configuration.
|
void |
reload()
reload configuration from file included registry
|
void |
removeChangeListener(org.apache.archiva.components.registry.RegistryListener listener) |
void |
removeListener(ConfigurationListener listener)
Remove a configuration listener to stop notifications of changes to the configuration.
|
void |
save(Configuration configuration)
Save any updated configuration.
|
void |
setAltConfigFilename(String altConfigFilename) |
void |
setRegistry(org.apache.archiva.components.registry.Registry registry) |
void |
setUserConfigFilename(String userConfigFilename) |
public DefaultArchivaConfiguration()
public Configuration getConfiguration()
ArchivaConfiguration
getConfiguration
in interface ArchivaConfiguration
public void save(Configuration configuration) throws IndeterminateConfigurationException, org.apache.archiva.components.registry.RegistryException
ArchivaConfiguration
save
in interface ArchivaConfiguration
configuration
- the configuration to saveIndeterminateConfigurationException
- if the configuration cannot be saved because it was read from two sourcesorg.apache.archiva.components.registry.RegistryException
- if there is a problem saving the registry datapublic void addListener(ConfigurationListener listener)
ArchivaConfiguration
addListener
in interface ArchivaConfiguration
listener
- the listenerpublic void removeListener(ConfigurationListener listener)
ArchivaConfiguration
removeListener
in interface ArchivaConfiguration
listener
- the listenerpublic void addChangeListener(org.apache.archiva.components.registry.RegistryListener listener)
ArchivaConfiguration
addChangeListener
in interface ArchivaConfiguration
listener
- the listener
TODO: Remove in future.public void removeChangeListener(org.apache.archiva.components.registry.RegistryListener listener)
removeChangeListener
in interface ArchivaConfiguration
@PostConstruct public void initialize()
public void reload()
ArchivaConfiguration
reload
in interface ArchivaConfiguration
public Locale getDefaultLocale()
getDefaultLocale
in interface ArchivaConfiguration
public List<Locale.LanguageRange> getLanguagePriorities()
getLanguagePriorities
in interface ArchivaConfiguration
public Path getAppServerBaseDir()
getAppServerBaseDir
in interface ArchivaConfiguration
public Path getRepositoryBaseDir()
ArchivaConfiguration
getRepositoryBaseDir
in interface ArchivaConfiguration
public Path getRemoteRepositoryBaseDir()
ArchivaConfiguration
getRemoteRepositoryBaseDir
in interface ArchivaConfiguration
public Path getRepositoryGroupBaseDir()
ArchivaConfiguration
getRepositoryGroupBaseDir
in interface ArchivaConfiguration
public Path getDataDirectory()
ArchivaConfiguration
getDataDirectory
in interface ArchivaConfiguration
public void beforeConfigurationChange(org.apache.archiva.components.registry.Registry registry, String propertyName, Object propertyValue)
beforeConfigurationChange
in interface org.apache.archiva.components.registry.RegistryListener
public void afterConfigurationChange(org.apache.archiva.components.registry.Registry registry, String propertyName, Object propertyValue)
afterConfigurationChange
in interface org.apache.archiva.components.registry.RegistryListener
public String getUserConfigFilename()
public String getAltConfigFilename()
public boolean isDefaulted()
ArchivaConfiguration
isDefaulted
in interface ArchivaConfiguration
public org.apache.archiva.components.registry.Registry getRegistry()
public void setRegistry(org.apache.archiva.components.registry.Registry registry)
public void setUserConfigFilename(String userConfigFilename)
public void setAltConfigFilename(String altConfigFilename)
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.