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


Java SystemConfiguration类代码示例

本文整理汇总了Java中org.apache.commons.configuration.SystemConfiguration的典型用法代码示例。如果您正苦于以下问题:Java SystemConfiguration类的具体用法?Java SystemConfiguration怎么用?Java SystemConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createLocalConfig

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
public static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
  ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();

  duplicateServiceCombConfigToCse(config,
      new ConcurrentMapConfiguration(new SystemConfiguration()),
      "configFromSystem");
  duplicateServiceCombConfigToCse(config,
      convertEnvVariable(new ConcurrentMapConfiguration(new EnvironmentConfiguration())),
      "configFromEnvironment");
  duplicateServiceCombConfigToCse(config,
      new DynamicConfiguration(
          new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()),
      "configFromYamlFile");

  return config;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:ConfigUtil.java

示例2: testFullOperation

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Test
public void testFullOperation() {
  // configuration from system properties
  ConcurrentMapConfiguration configFromSystemProperties =
      new ConcurrentMapConfiguration(new SystemConfiguration());
  // configuration from yaml file
  DynamicConfiguration configFromYamlFile =
      new DynamicConfiguration(yamlConfigSource(), new NeverStartPollingScheduler());
  // create a hierarchy of configuration that makes
  // 1) dynamic configuration source override system properties
  ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
  finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
  finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
  Assert.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5);

  Object o = finalConfig.getProperty("zq");
  @SuppressWarnings("unchecked")
  List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
  Assert.assertEquals(3, listO.size());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:TestYAMLConfigurationSource.java

示例3: Settings

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
/**
 * @author Wasiq B
 * @since 31-May-2015 9:23:00 pm
 */
private Settings () {
	super ();
	log.entry ();
	try {
		addConfiguration (new SystemConfiguration ());
		parseConfig ();
	}
	catch (final ConfigurationException | FileNotFoundException e) {
		try {
			throw new FrameworkException ("Load Settings", e);
		}
		catch (final FrameworkException e1) {
			log.catching (e1);
			log.error (ExceptionUtils.getRootCauseMessage (e1));
			log.error (ExceptionUtils.getStackTrace (e1));
		}
	}
	finally {
		log.exit ();
	}
}
 
开发者ID:WasiqB,项目名称:xtesy-framework,代码行数:26,代码来源:Settings.java

示例4: createConfiguration

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Override
protected Configuration createConfiguration(String name) throws ConfigurationException {
  CompositeConfiguration config = new CompositeConfiguration();
  config.addConfiguration(new SystemConfiguration());
  try {
    if (ConfigFactory.DEFAULT_CONFIG_NAME.equals(name)) {
      config.addConfiguration(new PropertiesConfiguration("config.properties"));
    } else {
      config.addConfiguration(new PropertiesConfiguration(name));
    }
  } catch (ConfigurationException e) {
    String message = "No properties file found: " + name
        + ". Using an empty BaseConfiguration instead.";
    if (ConfigFactory.DEFAULT_CONFIG_NAME.equals(name)) {
      LOG.info(message);
    } else {
      LOG.warn(message);
    }
    BaseConfiguration base = new BaseConfiguration();
    config.addConfiguration(base);
  }
  return config;
}
 
开发者ID:irenical,项目名称:jindy,代码行数:24,代码来源:CommonsSimpleImpl.java

示例5: createConfiguration

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
protected Configuration createConfiguration(final String overriddenPath) {
    try {

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("got overriddenPath {}", overriddenPath);
        }

        CompositeConfiguration compositeConfig = new CompositeConfiguration();
        // TODO: see how Systems and properties interact.
        compositeConfig.addConfiguration(new SystemConfiguration());
        compositeConfig.addConfiguration(findPropertiesConfiguration(overriddenPath));

        return compositeConfig;
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:18,代码来源:SshdSettingsBuilder.java

示例6: init

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
private synchronized static void init() {
    try {
        config = new CompositeConfiguration();
        config.setLogger(log);

        // 1 SystemConfiguration
        SystemConfiguration configSys = new SystemConfiguration();

        cfgMap = new HashMap<String, Configuration>();

        cfgMap.put("system", configSys);
        config.addConfiguration(configSys);
        log.debug("loading System Properties");

    } catch (Exception e) {
        log.error("load config file failed: " + ExceptionUtils.getFullStackTrace(e));
    }
}
 
开发者ID:jiucai,项目名称:appframework,代码行数:19,代码来源:ConfigUtil.java

示例7: load

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
public static CompositeConfiguration load(File source, boolean isRunServer) throws ConfigurationException {
      CompositeConfiguration config = new CompositeConfiguration();
      config.setListDelimiter(',');
      File customConfigFile = new File(source, LEGACY_CONFIG_FILE);
      if (customConfigFile.exists()) {
      	LEGACY_CONFIG_FILE_EXISTS = true;
          config.addConfiguration(new PropertiesConfiguration(customConfigFile));
      }
      customConfigFile = new File(source, CONFIG_FILE);
      if (customConfigFile.exists()) {
          config.addConfiguration(new PropertiesConfiguration(customConfigFile));
      }
      config.addConfiguration(new PropertiesConfiguration(DEFAULT_CONFIG_FILE));
      config.addConfiguration(new SystemConfiguration());
      if (isRunServer) {
	String port = config.getString(Keys.SERVER_PORT);
	config.setProperty(Keys.SITE_HOST, "http://localhost:"+port);
}
      return config;
  }
 
开发者ID:jbake-org,项目名称:jbake,代码行数:21,代码来源:ConfigUtil.java

示例8: getUserConfigFilename

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
private Optional<String> getUserConfigFilename() throws NamingException {
    CompositeConfiguration cc = new CompositeConfiguration();
    JNDIConfiguration jndi = new JNDIConfiguration();
    EnvironmentConfiguration env = new EnvironmentConfiguration();
    SystemConfiguration jvm = new SystemConfiguration();
    cc.addConfiguration(jvm);
    cc.addConfiguration(env);
    cc.addConfiguration(jndi);
    //
    final String CONFIG_FILENAME = (String) cc.getProperty("gladosWiki_configFile");
    if (false == Strings.isNullOrEmpty(CONFIG_FILENAME)) {
        LOG.debug(String.format("LOCAL-CONFIG CONFIG_FILENAME = %s", CONFIG_FILENAME));
        return Optional.of(CONFIG_FILENAME);
    } else {
        return Optional.absent();
    }
}
 
开发者ID:ageldama,项目名称:glados-wiki,代码行数:18,代码来源:GroovyConfigurer.java

示例9: setUp

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

	conf = new SystemConfiguration();

	// Create LZO Codec
	org.apache.hadoop.conf.Configuration hadoopConf = new org.apache.hadoop.conf.Configuration();
	GzipCodec gzipCodec = new GzipCodec();
	gzipCodec.setConf(hadoopConf);

	codec = gzipCodec;

	// Write out test file
	baseDir = new File(".", "target/testClientServerFailures/");
	baseDir.mkdirs();

	fileToStream = new File(baseDir, "test.txt");

	if (fileToStream.exists())
		fileToStream.delete();

	fileToStream.createNewFile();

	FileWriter writer = new FileWriter(fileToStream);
	BufferedWriter buffWriter = new BufferedWriter(writer);
	try {
		for (int i = 0; i < testLineCount; i++) {

			buffWriter.write(testString);
			buffWriter.write('\n');
		}
	} finally {
		buffWriter.close();
		writer.close();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:37,代码来源:TestFilesSendWorkerServerFailures.java

示例10: testReadProtocolWrongHeaderLen

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Test
public void testReadProtocolWrongHeaderLen() throws Exception {

	ByteArrayOutputStream output = new ByteArrayOutputStream();
	DataOutputStream datOut = new DataOutputStream(output);

	// write the wrong length for the header length.
	// no further data is needed as we expect the Protocol to fail on this
	try {
		byte[] namebytes = GzipCodec.class.getName().getBytes();
		datOut.writeInt(namebytes.length);
		datOut.write(namebytes);
		datOut.writeInt(1000);
		datOut.write("test".getBytes()); // this data is normally compressed
											// but we expect the code to
											// fail when reading the
		// lengths
	} finally {
		datOut.close();
		output.close();
	}

	CompressionPoolFactory pf = new CompressionPoolFactoryImpl(10, 10,
			new AgentStatusImpl());
	ProtocolImpl p = new ProtocolImpl(pf);

	Configuration conf = new SystemConfiguration();

	ByteArrayInputStream in = new ByteArrayInputStream(output.toByteArray());
	try {
		p.read(conf, new DataInputStream(in));
		assertTrue(false);
	} catch (Throwable t) {
		assertTrue(true);
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:37,代码来源:TestProtocolImpl.java

示例11: testReadProtocolWrongCompressionLen

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Test
public void testReadProtocolWrongCompressionLen() throws Exception {

	ByteArrayOutputStream output = new ByteArrayOutputStream();
	DataOutputStream datOut = new DataOutputStream(output);

	// write the wrong length for the header.
	// no further data is needed as we expect the Protocol to fail on this
	try {
		datOut.writeInt(400);
		datOut.write(GzipCodec.class.getName().getBytes());
	} finally {
		datOut.close();
		output.close();
	}

	CompressionPoolFactory pf = new CompressionPoolFactoryImpl(10, 10,
			new AgentStatusImpl());

	ProtocolImpl p = new ProtocolImpl(pf);

	Configuration conf = new SystemConfiguration();

	ByteArrayInputStream in = new ByteArrayInputStream(output.toByteArray());
	try {
		p.read(conf, new DataInputStream(in));
		assertTrue(false);
	} catch (Throwable t) {
		assertTrue(true);
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:32,代码来源:TestProtocolImpl.java

示例12: testConfigCheckOK

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Test
public void testConfigCheckOK() throws Exception {

	ConfigCheck check = new ConfigCheck(new SystemConfiguration());
	check.runCheck();
	assertTrue(true);

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:TestConfigCheck.java

示例13: locate

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Override
	public PropertySource<?> locate(Environment environment) {
		
		try {
			// configuration from local properties file
			ConcurrentMapConfiguration configFromPropertiesFile = new ConcurrentMapConfiguration(new PropertiesConfiguration("application.yml"));
			
			// configuration from system properties
			ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
			
			// configuration from a dynamic source
//			PolledConfigurationSource source = new NetflixUrlPolledConfigurationSource();
			PolledConfigurationSource source = new NetflixEurekaPolledConfigurationSource();
			AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler();
			DynamicConfiguration dynamicConfiguration = new DynamicConfiguration(source, scheduler);
			
			// create a hierarchy of configuration that makes
			// 1) dynamic configuration source override system properties
			// 2) system properties override properties file
			ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
			finalConfig.addConfiguration(dynamicConfiguration, "dynamicConfig");
			finalConfig.addConfiguration(configFromSystemProperties, "systemConfig");
			finalConfig.addConfiguration(configFromPropertiesFile, "fileConfig");
			
			// install with ConfigurationManager so that finalConfig
			// becomes the source of dynamic properties
			ConfigurationManager.install(finalConfig);
		} catch(Exception e) {
			logger.error(e.getMessage());
		}
		
		return null;
	}
 
开发者ID:colddew,项目名称:micro-service-netflix,代码行数:34,代码来源:NetflixPropertySourceLocator.java

示例14: createConfig

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
@Override
public Config createConfig(String name) {
  try {
    final CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new PropertiesConfiguration("test.properties"));
    return new ApacheTestConfig(config);
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:irenical,项目名称:jindy,代码行数:12,代码来源:ApacheTestFactory.java

示例15: main

import org.apache.commons.configuration.SystemConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
  if (args.length < 1 || args.length > 2) {
    printUsage();
  }
  Closer closer = Closer.create();
  try {
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    if (args.length == 2) {
      config.addConfiguration(new PropertiesConfiguration(args[1]));
    }
    Properties properties = getProperties(config);
    DatabaseJobHistoryStoreSchemaManager schemaManager =
            closer.register(DatabaseJobHistoryStoreSchemaManager.builder(properties).build());
    if (String.CASE_INSENSITIVE_ORDER.compare("migrate", args[0]) == 0) {
      schemaManager.migrate();
    } else if (String.CASE_INSENSITIVE_ORDER.compare("info", args[0]) == 0) {
      schemaManager.info();
    } else {
      printUsage();
    }
  } catch (Throwable t) {
    throw closer.rethrow(t);
  } finally {
    closer.close();
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:28,代码来源:DatabaseJobHistoryStoreSchemaManager.java


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