当前位置: 首页>>代码示例>>Java>>正文


Java XMLConfiguration.setExpressionEngine方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.XMLConfiguration.setExpressionEngine方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfiguration.setExpressionEngine方法的具体用法?Java XMLConfiguration.setExpressionEngine怎么用?Java XMLConfiguration.setExpressionEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.setExpressionEngine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addXmlConfiguration

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private XMLConfiguration addXmlConfiguration(final Settings4jRepository testSettings, final String connectorName,
        final String fileName, final String propertyDelimiter) throws ConfigurationException {
    ConfigurationToConnectorAdapter connector = (ConfigurationToConnectorAdapter) testSettings.getSettings()//
        .getConnector(connectorName);
    if (connector == null) {
        final File iniConfig = new File(TestUtils.getTestFolder(), "helper/configuration/" + fileName);
        iniConfig.delete();
        XMLConfiguration configuration = new XMLConfiguration(iniConfig);
        final DefaultExpressionEngine expressionEngine = new DefaultExpressionEngine();
        expressionEngine.setPropertyDelimiter(propertyDelimiter);
        configuration.setExpressionEngine(expressionEngine);

        connector = new ConfigurationToConnectorAdapter(connectorName, configuration);

        testSettings.getSettings().addConnector(connector, //
            ConnectorPositions.firstValid(//
                ConnectorPositions.afterLast(SystemPropertyConnector.class), //
                ConnectorPositions.atFirst() // if no SystemPropertyConnector is configured.
                )//
            );

    }
    return (XMLConfiguration) connector.getConfiguration();
}
 
开发者ID:brabenetz,项目名称:settings4j,代码行数:25,代码来源:ConfigurationToConnectorAdapterTest.java

示例2: main

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static void main (String[]args) throws ConfigurationException, HTAPBException{
    // Initialize log4j
    String log4jPath = System.getProperty("log4j.configuration");
    if (log4jPath != null) {
        org.apache.log4j.PropertyConfigurator.configure(log4jPath);
    } else {
        throw new RuntimeException("Missing log4j.properties file");
    }
    
    String configFile = "config/htapb_config_postgres.xml";
    XMLConfiguration xmlConfig = new XMLConfiguration(configFile);
    xmlConfig.setExpressionEngine(new XPathExpressionEngine());
    
    
    WorkloadSetup setup = new WorkloadSetup(xmlConfig);
    setup.computeWorkloadSetup();
    
    
    DensityConsultant density = new DensityConsultant(10000);
    System.out.println("Density: "+density.getDensity());
    System.out.println("Delta TS: "+density.getDeltaTs());
    System.out.println("Target TPS "+density.getTargetTPS());
    
    long deltaTs = density.getDeltaTs();
    
    Clock clock = new Clock(deltaTs,false);
    
    System.out.println("Clock: current TS "+clock.getCurrentTs());

    int year = RandomParameters.randBetween(1993, 1997);
    int month = RandomParameters.randBetween(1, 12);
    long date1 = RandomParameters.convertDatetoLong(year, month, 1);
    long date2 = RandomParameters.convertDatetoLong(year+1, month, 1);
    Timestamp ts1 = new Timestamp(clock.transformTsFromSpecToLong(date1));  
    Timestamp ts2 = new Timestamp(clock.transformTsFromSpecToLong(date2));
    
    System.out.println(ts1.toString());
    System.out.println(ts2.toString());
    
}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:41,代码来源:RandomExecutor.java

示例3: JBrickConfigManager

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private JBrickConfigManager(String pStrConfigurationFilePath) {
       mXMLConfiguration = new XMLConfiguration();
       mXMLConfiguration.setFileName(pStrConfigurationFilePath);
       mXMLConfiguration.setExpressionEngine(new XPathExpressionEngine());
	try {
		mXMLConfiguration.load();
	} catch (ConfigurationException e) {
		mLog.error(e,"Error while reading configuration from file ",this.getStrConfigFileName());
		throw new JBrickException(e, "jBrickException.configManager.errorWhileReadingConfiguration", e.getMessage());
	}
	mLog.debug("ConfigManager initialized using file ", pStrConfigurationFilePath);
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:13,代码来源:JBrickConfigManager.java

示例4: read

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static XMLConfiguration read(String src) {
	try {
		// remove all namespaces from xml
		src = removeNSAndPreamble(src);
		XMLConfiguration config = new XMLConfiguration();
		config.setDelimiterParsingDisabled(true);
		config.load(new ByteArrayInputStream(src.getBytes()));
		config.setExpressionEngine(new XPathExpressionEngine());
		return config;

	} catch (ConfigurationException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:15,代码来源:XPathUtils.java

示例5: readConfig

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
     * Constructor pulls file out of the jar or reads from disk and sets up refresh policy.
     * 
     * @param expressionEngine
     *            the expression engine to use. Null results in default expression engine
     */
    protected void readConfig() {
        try {
            ExpressionEngine expressionEngine = new XPathExpressionEngine();
            String configPath = getConfigName();
            FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();

            File dataDirConfigFile = new File(configPath);
//            LOG.info("Reading settings from " + dataDirConfigFile.getAbsolutePath());
            if (!dataDirConfigFile.exists()) {
                // Load a default from the classpath:
                // Note: we don't let new XMLConfiguration() lookup the resource
                // url directly because it may not be able to find the desired
                // classloader to load the URL from.
                URL configResourceUrl = this.getClass().getClassLoader().getResource(configPath);
                if (configResourceUrl == null) {
                    throw new RuntimeException("unable to load resource: " + configPath);
                }

                XMLConfiguration tmpConfig = new XMLConfiguration(configResourceUrl);
                // Copy over a default configuration since none exists:
                // Ensure data dir location exists:
                if (dataDirConfigFile.getParentFile() != null && !dataDirConfigFile.getParentFile().exists()
                        && !dataDirConfigFile.getParentFile().mkdirs()) {
                    throw new RuntimeException("could not create directories.");
                }
                tmpConfig.save(dataDirConfigFile);
                LOG.info("Saving settings file to " + dataDirConfigFile.getAbsolutePath());
            }

            if (dataDirConfigFile.exists()) {
                config = new XMLConfiguration(dataDirConfigFile);
            } else {
                // extract from jar and write to
                throw new IllegalStateException("Config file does not exist or cannot be created");
            }
            if (expressionEngine != null) {
                config.setExpressionEngine(expressionEngine);
            }
            configFile = dataDirConfigFile;
            // reload at most once per thirty seconds on configuration queries.
            config.setReloadingStrategy(reloadingStrategy);
            initConfig(config);
        } catch (ConfigurationException e) {
            LOG.error("Error reading settings file: " + e, e);
            throw new RuntimeException(e);
        }
    }
 
开发者ID:intuit,项目名称:Tank,代码行数:54,代码来源:BaseCommonsXmlConfig.java


注:本文中的org.apache.commons.configuration.XMLConfiguration.setExpressionEngine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。