List of usage examples for org.apache.commons.configuration2.tree DefaultExpressionEngine DefaultExpressionEngine
public DefaultExpressionEngine(final DefaultExpressionEngineSymbols syms)
From source file:com.gs.obevo.api.factory.XmlFileConfigReader.java
@Override public HierarchicalConfiguration getConfig(FileObject checkoutFolder) { try {/*from ww w . j a va2 s . co m*/ FileObject envFileToRead = getEnvFileToRead(checkoutFolder); if (envFileToRead.getName().getExtension().equals("xml")) { // For the XML lookup, we want all access to fall to attribute queries if we choose. To do that, we override // the expression engine. DefaultExpressionEngine engine = new DefaultExpressionEngine( DefaultExpressionEngineSymbols.DEFAULT_SYMBOLS) { @Override public <T> List<QueryResult<T>> query(T root, String key, NodeHandler<T> handler) { List<QueryResult<T>> results = super.query(root, key, handler); if (!results.isEmpty()) { return results; } // If we find no results, fall back to the query that specifies the attribute handler return super.query(root, this.attributeKey(null, key), handler); } }; XMLConfiguration configuration = new FileBasedConfigurationBuilder<>(XMLConfiguration.class) .configure(new Parameters().hierarchical().setURL(envFileToRead.getURLDa()) .setListDelimiterHandler(new DisabledListDelimiterHandler()) .setExpressionEngine(engine)) .getConfiguration(); postProcess(configuration); return configuration; } else { return new FileBasedConfigurationBuilder<>(FixedYAMLConfiguration.class) .configure(new Parameters().hierarchical().setURL(envFileToRead.getURLDa()) .setListDelimiterHandler(new DisabledListDelimiterHandler())) .getConfiguration(); } } catch (ConfigurationException e) { throw new DeployerRuntimeException(e); } }