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


Java Configuration.setProperty方法代码示例

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


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

示例1: savePropertyForStandaloneProfile

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
/**
 * Save property for standalone profile.
 *
 * @param pair the pair
 */
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
    try {
        final File file = getStandaloneProfileConfigurationDirectory();
        final Parameters params = new Parameters();

        final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                        .configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));

        final Configuration config = builder.getConfiguration();
        config.setProperty(pair.getKey(), pair.getValue());
        builder.save();
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:CasConfigurationPropertiesEnvironmentManager.java

示例2: test

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
@Test
public void test() throws ConfigurationException {

    // Null input.  (= Default value.)
    assertEquals(VERSION.fetch(null), VERSION.getDefaultValue());

    // Not found. (= Default value.)
    Configuration conf = new MapConfiguration(new HashMap<>());
    assertEquals(VERSION.fetch(conf), VERSION.getDefaultValue());

    // Retrieved from properties. (Empty)
    conf.setProperty(VERSION.getKey(), "");
    assertNull(VERSION.fetch(conf));

    // Retrieved from properties. (Configured)
    conf.setProperty(VERSION.getKey(), "test");
    assertEquals(VERSION.fetch(conf), "test");

}
 
开发者ID:after-the-sunrise,项目名称:bitflyer4j,代码行数:20,代码来源:KeyTypeTest.java

示例3: testOverride

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
@Test
public void testOverride() {

    Parameters params = new Parameters();
    FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
            new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                    .configure(params.properties()
                            .setFileName("file.properties"));
    Configuration config = null;
    try {
        config = builder.getConfiguration();
        config.setProperty("somekey", "somevalue");
        builder.save();
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:bejondshao,项目名称:personal,代码行数:18,代码来源:PropertyOverrideTest.java

示例4: getClientConfiguration

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
public Configuration getClientConfiguration() {
    Configuration clientConfig = new CompositeConfiguration();
    Iterator<String> iter = getKeys();
    while (iter.hasNext()) {
        String key = iter.next();
        if (key.startsWith(CLIENT_PREFIX)) {
            clientConfig.setProperty(key, getProperty(key));
        }
    }
    return clientConfig;
}
 
开发者ID:level11data,项目名称:databricks-client-java,代码行数:12,代码来源:DatabricksClientConfiguration.java

示例5: setProperty

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
public static void setProperty(final PropertyList property, final String value) {
    try {
        Configuration config = FILE_BASED_CONFIGURATION_BUILDER.getConfiguration();
        config.setProperty(property.toString(), value);
        FILE_BASED_CONFIGURATION_BUILDER.save();
    } catch (ConfigurationException cex) {
        LOGGER.error("\n" + cex.getCause());
        cex.printStackTrace();
    }
}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:11,代码来源:PropertiesHelper.java

示例6: yajswInstall

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
public boolean yajswInstall(String configuration)
{
		WrappedService w = new WrappedService();
		Configuration c = w.getLocalConfiguration();
		c.setProperty("wrapper.config", configuration);
		w.init();
		return w.install();
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:9,代码来源:WinServiceManagerServer.java

示例7: main

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
public static void main(String[] args)
{
	WrappedRuntimeProcess p = new WrappedRuntimeProcess();
	Configuration c = p.getLocalConfiguration();
	c.setProperty("wrapper.image", "notepad");// "test.bat");//notepad");//"c:/temp/test.bat");//
	c.setProperty("wrapper.working.dir", "c:/");
	p.init();
	p.start();
	p.waitFor(10000);
	System.out.println("stopping");
	p.stop();
	System.out.println("stopped " + p.getExitCode());
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:14,代码来源:WrappedRuntimeProcess.java

示例8: main

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
/**
 * The main method.
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args)
{
	Configuration conf = new BaseConfiguration();
	conf.setProperty("wrapper.java.command", "java");
	WindowsJavaHome javaHome = new WindowsJavaHome(conf);
	System.out.println(javaHome.findJava(
			conf.getString("wrapper.java.command"),
			conf.getString("wrapper.java.command")));

	conf.setProperty("wrapper.java.customProcName", "test");
	javaHome = new WindowsJavaHome(conf);
	System.out.println(javaHome.findJava(
			conf.getString("wrapper.java.command"),
			conf.getString("wrapper.java.command")));

	conf.setProperty("wrapper.java.command", "javaw");
	javaHome = new WindowsJavaHome(conf);
	System.out.println(javaHome.findJava(
			conf.getString("wrapper.java.command"),
			conf.getString("wrapper.java.command")));

	conf.clear();
	conf.setProperty("wrapper.java.minversion", "1.5.0");
	conf.setProperty("wrapper.java.maxversion", "1.5.99");
	conf.setProperty("wrapper.java.customProcName", "test");
	javaHome = new WindowsJavaHome(conf);
	System.out.println(javaHome.findJava(
			conf.getString("wrapper.java.command"),
			conf.getString("wrapper.java.command")));

	conf.clear();
	conf.setProperty("wrapper.java.minversion", "1.6.0");
	conf.setProperty("wrapper.java.customProcName", "test");
	conf.setProperty("wrapper.java.preferJdk", true);
	javaHome = new WindowsJavaHome(conf);
	System.out.println(javaHome.findJava(
			conf.getString("wrapper.java.command"),
			conf.getString("wrapper.java.command")));

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:47,代码来源:WindowsJavaHome.java

示例9: stopOsProcess

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
private void stopOsProcess(int shutdownWaitTime)
{
	boolean externalStop = false;
	String stopConfigName = _config.getString("wrapper.stop.conf");
	File stopConfigFile = null;
	if (stopConfigName != null)
	{
		getWrapperLogger().info(
				"using stop configuration " + stopConfigName);
		stopConfigFile = new File(stopConfigName);
		stopConfigName = stopConfigFile.getAbsolutePath();
		externalStop = stopConfigFile.isFile() && stopConfigFile.exists();
		if (!externalStop)
			getWrapperLogger().severe(
					"error accessing stop configuration " + stopConfigName);
	}
	WrappedProcess stopper = null;
	if (externalStop)
	{
		getWrapperLogger().info("starting stop application");
		Configuration stopLocalConf = new BaseConfiguration();
		stopLocalConf.setProperty("wrapper.config", stopConfigName);
		YajswConfigurationImpl stopConf = new YajswConfigurationImpl(
				stopLocalConf, _useSystemProperties);
		stopper = WrappedProcessFactory.createProcess(stopConf);
		stopper.getLocalConfiguration().setProperty("wrapper.config",
				stopConfigName);
		stopper.setUseSystemProperties(_useSystemProperties);
		stopper.setStopper(true);
		// stopper.setDebug(true);
		stopper.init();
		stopper.start();
	}

	// else normally process is stopped by the controller
	// _osProcess.stop(shutdownWaitTime, 999);

	if (shutdownWaitTime > 0)
		_osProcess.waitFor(shutdownWaitTime);

	long remainStopWait = getRemainStopWaitTime();
	while (_osProcess.isRunning() && remainStopWait > 0)
	{
		if (_debug > 1)
			getAppLogger().info("extending wait time " + remainStopWait);

		if (_service != null)
			((StopableService) _service).signalStopping(remainStopWait);
		_osProcess.waitFor(remainStopWait);
		remainStopWait = getRemainStopWaitTime();
	}
	if (_osProcess.isRunning())
	{
		getWrapperLogger().info(
				"process did not stop after " + shutdownWaitTime
						+ " sec. -> hard kill");
	}
	_osProcess.kill(999);

	if (stopper != null && stopper.getState() != STATE_IDLE)
		stopper.stop();

	// give the OS some time to clean up
	try
	{
		Thread.sleep(500);
	}
	catch (InterruptedException e)
	{
		e.printStackTrace();
		Thread.currentThread().interrupt();
	}
	_osProcess.destroy();

	// if (_debug > 0)
	getWrapperLogger().info(
			"process exit code: " + _osProcess.getExitCode());
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:79,代码来源:AbstractWrappedProcess.java


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