當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。