Search in sources :

Example 1 with EvaluatorException

use of org.apache.archiva.components.evaluator.EvaluatorException in project archiva by apache.

the class DefaultArchivaConfiguration method initialize.

@PostConstruct
public void initialize() {
    // Resolve expressions in the userConfigFilename and altConfigFilename
    try {
        ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator();
        expressionEvaluator.addExpressionSource(new SystemPropertyExpressionSource());
        String userConfigFileNameSysProps = System.getProperty(USER_CONFIG_PROPERTY);
        if (StringUtils.isNotBlank(userConfigFileNameSysProps)) {
            userConfigFilename = userConfigFileNameSysProps;
        } else {
            String userConfigFileNameEnv = System.getenv(USER_CONFIG_ENVVAR);
            if (StringUtils.isNotBlank(userConfigFileNameEnv)) {
                userConfigFilename = userConfigFileNameEnv;
            } 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 : EvaluatorException(org.apache.archiva.components.evaluator.EvaluatorException) DefaultExpressionEvaluator(org.apache.archiva.components.evaluator.DefaultExpressionEvaluator) ExpressionEvaluator(org.apache.archiva.components.evaluator.ExpressionEvaluator) RegistryException(org.apache.archiva.components.registry.RegistryException) DefaultExpressionEvaluator(org.apache.archiva.components.evaluator.DefaultExpressionEvaluator) SystemPropertyExpressionSource(org.apache.archiva.components.evaluator.sources.SystemPropertyExpressionSource) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 DefaultExpressionEvaluator (org.apache.archiva.components.evaluator.DefaultExpressionEvaluator)1 EvaluatorException (org.apache.archiva.components.evaluator.EvaluatorException)1 ExpressionEvaluator (org.apache.archiva.components.evaluator.ExpressionEvaluator)1 SystemPropertyExpressionSource (org.apache.archiva.components.evaluator.sources.SystemPropertyExpressionSource)1 RegistryException (org.apache.archiva.components.registry.RegistryException)1