Search in sources :

Example 1 with SystemPropertyExpressionSource

use of org.apache.archiva.redback.components.evaluator.sources.SystemPropertyExpressionSource in project archiva by apache.

the class DefaultArchivaConfiguration method initialize.

@PostConstruct
public void initialize() {
    this.postPolicies = componentContainer.buildMapWithRole(PostDownloadPolicy.class);
    this.prePolicies = componentContainer.buildMapWithRole(PreDownloadPolicy.class);
    this.downloadErrorPolicies = componentContainer.buildMapWithRole(DownloadErrorPolicy.class);
    // Resolve expressions in the userConfigFilename and altConfigFilename
    try {
        ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator();
        expressionEvaluator.addExpressionSource(new SystemPropertyExpressionSource());
        String userConfigFileNameSysProps = System.getProperty("archiva.user.configFileName");
        if (StringUtils.isNotBlank(userConfigFileNameSysProps)) {
            userConfigFilename = userConfigFileNameSysProps;
        } else {
            userConfigFilename = expressionEvaluator.expand(userConfigFilename);
        }
        altConfigFilename = expressionEvaluator.expand(altConfigFilename);
        loadConfiguration();
        handleUpgradeConfiguration();
    } catch (IndeterminateConfigurationException | RegistryException e) {
        throw new RuntimeException("failed during upgrade from previous version" + e.getMessage(), e);
    } catch (EvaluatorException e) {
        throw new RuntimeException("Unable to evaluate expressions found in " + "userConfigFilename or altConfigFilename.", e);
    }
    registry.addChangeListener(this);
}
Also used : PostDownloadPolicy(org.apache.archiva.policies.PostDownloadPolicy) PreDownloadPolicy(org.apache.archiva.policies.PreDownloadPolicy) EvaluatorException(org.apache.archiva.redback.components.evaluator.EvaluatorException) DownloadErrorPolicy(org.apache.archiva.policies.DownloadErrorPolicy) ExpressionEvaluator(org.apache.archiva.redback.components.evaluator.ExpressionEvaluator) DefaultExpressionEvaluator(org.apache.archiva.redback.components.evaluator.DefaultExpressionEvaluator) RegistryException(org.apache.archiva.redback.components.registry.RegistryException) DefaultExpressionEvaluator(org.apache.archiva.redback.components.evaluator.DefaultExpressionEvaluator) SystemPropertyExpressionSource(org.apache.archiva.redback.components.evaluator.sources.SystemPropertyExpressionSource) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 DownloadErrorPolicy (org.apache.archiva.policies.DownloadErrorPolicy)1 PostDownloadPolicy (org.apache.archiva.policies.PostDownloadPolicy)1 PreDownloadPolicy (org.apache.archiva.policies.PreDownloadPolicy)1 DefaultExpressionEvaluator (org.apache.archiva.redback.components.evaluator.DefaultExpressionEvaluator)1 EvaluatorException (org.apache.archiva.redback.components.evaluator.EvaluatorException)1 ExpressionEvaluator (org.apache.archiva.redback.components.evaluator.ExpressionEvaluator)1 SystemPropertyExpressionSource (org.apache.archiva.redback.components.evaluator.sources.SystemPropertyExpressionSource)1 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)1