@Service(value="archivaConfiguration#default") public class DefaultArchivaConfiguration extends Object implements ArchivaConfiguration, org.apache.archiva.redback.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.
Modifier and Type | Field and Description |
---|---|
private String |
altConfigFilename
see #initialize
default-value="${appserver.base}/conf/archiva.xml"
|
private org.apache.archiva.redback.components.springutils.ComponentContainer |
componentContainer |
private Configuration |
configuration
The configuration that has been converted.
|
private Map<String,DownloadErrorPolicy> |
downloadErrorPolicies
see #initialize
|
private boolean |
isConfigurationDefaulted
Boolean to help determine if the configuration exists as a result of pulling in
the default-archiva.xml
|
private static String |
KEY |
private static String |
KEY_DEFAULT_ONLY |
private Set<ConfigurationListener> |
listeners
Configuration Listeners we've registered.
|
private org.slf4j.Logger |
log |
private Map<String,PostDownloadPolicy> |
postPolicies
see #initialize
|
private Map<String,PreDownloadPolicy> |
prePolicies
see #initialize
|
private org.apache.archiva.redback.components.registry.Registry |
registry
Plexus registry to read the configuration from.
|
private Set<org.apache.archiva.redback.components.registry.RegistryListener> |
registryListeners
Registry Listeners we've registered.
|
private String |
userConfigFilename
see #initialize
default-value="${user.home}/.m2/archiva.xml"
|
Constructor and Description |
---|
DefaultArchivaConfiguration() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(org.apache.archiva.redback.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.
|
private void |
addRegistryChangeListener(org.apache.archiva.redback.components.registry.RegistryListener listener) |
void |
afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
void |
beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry,
String propertyName,
Object propertyValue) |
private Configuration |
checkRepositoryLocations(Configuration config) |
private org.apache.archiva.redback.components.registry.Registry |
createDefaultConfigurationFile() |
private String |
escapeCronExpression(String cronExpression) |
private void |
escapeCronExpressions(Configuration configuration) |
private Policy |
findPolicy(String policyId) |
String |
getAltConfigFilename() |
Configuration |
getConfiguration()
Get the configuration.
|
org.apache.archiva.redback.components.registry.Registry |
getRegistry() |
String |
getUserConfigFilename() |
private void |
handleUpgradeConfiguration()
Handle upgrade to newer version
|
private boolean |
hasConfigVersionChanged(Configuration current,
org.apache.archiva.redback.components.registry.Registry defaultOnlyConfiguration) |
void |
initialize() |
boolean |
isDefaulted()
Determines if the configuration in use was as a result of a defaulted configuration.
|
private Configuration |
load() |
private Configuration |
loadConfiguration() |
private boolean |
policyExists(String policyId) |
private org.apache.archiva.redback.components.registry.Registry |
readDefaultConfiguration() |
private org.apache.archiva.redback.components.registry.Registry |
readDefaultOnlyConfiguration() |
private RepositoryCheckPath |
readRepositoryCheckPath(org.apache.archiva.redback.components.registry.Registry registry) |
void |
reload()
reload configuration from file included registry
|
void |
removeChangeListener(org.apache.archiva.redback.components.registry.RegistryListener listener) |
private String |
removeExpressions(String directory) |
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.redback.components.registry.Registry registry) |
void |
setUserConfigFilename(String userConfigFilename) |
private void |
triggerEvent(int type) |
private String |
unescapeCronExpression(String cronExpression) |
private Configuration |
unescapeExpressions(Configuration config) |
private void |
updateCheckPathDefaults(Configuration config,
org.apache.archiva.redback.components.registry.Registry defaultConfiguration) |
private boolean |
writeFile(String filetype,
String path,
String contents)
Attempts to write the contents to a file, if an IOException occurs, return false.
|
private org.slf4j.Logger log
@Inject @Named(value="commons-configuration") private org.apache.archiva.redback.components.registry.Registry registry
@Inject private org.apache.archiva.redback.components.springutils.ComponentContainer componentContainer
private Configuration configuration
private Map<String,PreDownloadPolicy> prePolicies
private Map<String,PostDownloadPolicy> postPolicies
private Map<String,DownloadErrorPolicy> downloadErrorPolicies
private String userConfigFilename
private String altConfigFilename
private Set<ConfigurationListener> listeners
private Set<org.apache.archiva.redback.components.registry.RegistryListener> registryListeners
private boolean isConfigurationDefaulted
private static final String KEY
private static final String KEY_DEFAULT_ONLY
public DefaultArchivaConfiguration()
public Configuration getConfiguration()
ArchivaConfiguration
getConfiguration
in interface ArchivaConfiguration
private Configuration loadConfiguration()
private boolean hasConfigVersionChanged(Configuration current, org.apache.archiva.redback.components.registry.Registry defaultOnlyConfiguration)
private Configuration load()
private void updateCheckPathDefaults(Configuration config, org.apache.archiva.redback.components.registry.Registry defaultConfiguration)
private RepositoryCheckPath readRepositoryCheckPath(org.apache.archiva.redback.components.registry.Registry registry)
private Policy findPolicy(String policyId)
private boolean policyExists(String policyId)
private org.apache.archiva.redback.components.registry.Registry readDefaultConfiguration()
private org.apache.archiva.redback.components.registry.Registry readDefaultOnlyConfiguration()
public void save(Configuration configuration) throws IndeterminateConfigurationException, org.apache.archiva.redback.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.redback.components.registry.RegistryException
- if there is a problem saving the registry dataprivate void escapeCronExpressions(Configuration configuration)
private org.apache.archiva.redback.components.registry.Registry createDefaultConfigurationFile() throws org.apache.archiva.redback.components.registry.RegistryException
org.apache.archiva.redback.components.registry.RegistryException
private boolean writeFile(String filetype, String path, String contents)
filetype
- the filetype (freeform text) to use in logging messages when failure to write.path
- the path to write to.contents
- the contents to write.private void triggerEvent(int type)
public 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.redback.components.registry.RegistryListener listener)
ArchivaConfiguration
addChangeListener
in interface ArchivaConfiguration
listener
- the listener
TODO: Remove in future.private void addRegistryChangeListener(org.apache.archiva.redback.components.registry.RegistryListener listener)
public void removeChangeListener(org.apache.archiva.redback.components.registry.RegistryListener listener)
removeChangeListener
in interface ArchivaConfiguration
@PostConstruct public void initialize()
private void handleUpgradeConfiguration() throws org.apache.archiva.redback.components.registry.RegistryException, IndeterminateConfigurationException
org.apache.archiva.redback.components.registry.RegistryException
IndeterminateConfigurationException
public void reload()
ArchivaConfiguration
reload
in interface ArchivaConfiguration
public void beforeConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
beforeConfigurationChange
in interface org.apache.archiva.redback.components.registry.RegistryListener
public void afterConfigurationChange(org.apache.archiva.redback.components.registry.Registry registry, String propertyName, Object propertyValue)
afterConfigurationChange
in interface org.apache.archiva.redback.components.registry.RegistryListener
private String removeExpressions(String directory)
private String unescapeCronExpression(String cronExpression)
private String escapeCronExpression(String cronExpression)
private Configuration unescapeExpressions(Configuration config)
private Configuration checkRepositoryLocations(Configuration config)
public String getUserConfigFilename()
public String getAltConfigFilename()
public boolean isDefaulted()
ArchivaConfiguration
isDefaulted
in interface ArchivaConfiguration
public org.apache.archiva.redback.components.registry.Registry getRegistry()
public void setRegistry(org.apache.archiva.redback.components.registry.Registry registry)
public void setUserConfigFilename(String userConfigFilename)
public void setAltConfigFilename(String altConfigFilename)
Copyright © 2006–2023 The Apache Software Foundation. All rights reserved.