List of usage examples for org.apache.commons.configuration SystemConfiguration SystemConfiguration
public SystemConfiguration()
From source file:com.caricah.iotracah.bootstrap.runner.impl.DefaultRunner.java
/** * Initializes this instance./*from w w w.ja v a 2 s. co m*/ * <p> * This method should be called once the JVM process is created and the * <code>Runner</code> instance is created thru its empty public * constructor. * </p> * <p> * Apart from set up and allocation of native resources, this method * does not start actual operation of <code>Runner</code> (such * as starting threads.) as it would impose serious security hazards. The * start of operation must be performed in the <code>start()</code> * method. * </p> * * @throws UnRetriableException Any exception preventing a successful * initialization. */ @Override public void init() throws UnRetriableException { log.trace(" init : initializing system configurations"); //First load the system settings as the defaults. CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); setConfiguration(configuration); log.info(" init : {} set to : {}", "iotracah.pidfile", System.getProperty("iotracah.pidfile")); log.info(" init : {} set to : {}", "iotracah.default.path.home", System.getProperty("iotracah.default.path.home")); log.info(" init : {} set to : {}", "iotracah.default.path.logs", System.getProperty("iotracah.default.path.logs")); log.info(" init : {} set to : {}", "iotracah.default.path.data", System.getProperty("iotracah.default.path.data")); log.info(" init : {} set to : {}", "iotracah.default.path.conf", System.getProperty("iotracah.default.path.conf")); for (ConfigHandler configHandler : getConfigurationSetLoader()) { log.debug(" init : found the configuration handler {} ", configHandler); Configuration newConfigs = configHandler.populateConfiguration(getConfiguration()); setConfiguration(newConfigs); } for (LogHandler logHandler : getLogSetLoader()) { log.debug(" init : Configuring logging using handler {} ", logHandler); logHandler.configure(getConfiguration()); } }
From source file:io.fabric8.apiman.ManagerApiMicroServiceConfig.java
@PostConstruct protected void postConstruct() { String host = null;//from w w w. j av a 2 s .com try { InetAddress initAddress = InetAddress.getByName("ELASTICSEARCH"); host = initAddress.getCanonicalHostName(); } catch (UnknownHostException e) { log.error("Could not resolve DNS for ELASTICSEARCH, trying ENV settings next.", e); } String hostAndPort = Systems.getServiceHostAndPort("ELASTICSEARCH", "localhost", "9200"); String[] hp = hostAndPort.split(":"); if (host == null) { log.info("ELASTICSEARCH host:port is set to " + hostAndPort + " using ENV settings."); host = hp[0]; } String protocol = Systems.getEnvVarOrSystemProperty("ELASTICSEARCH_PROTOCOL", "http"); System.out.println("*** Connecting to Elastic at service " + protocol + "://" + host + ":" + hp[1]); log.debug("CONNECTING TO 'elasticsearch' on " + protocol + "://" + host + ":" + hp[1]); config = new SystemConfiguration(); config.setProperty(APIMAN_MANAGER_STORAGE_ES_HOST, host); config.setProperty(APIMAN_MANAGER_STORAGE_ES_PORT, hp[1]); config.setProperty(APIMAN_MANAGER_STORAGE_ES_PROTOCOL, protocol); config.setProperty(APIMAN_MANAGER_STORAGE_ES_CLUSTER_NAME, "elasticsearch"); }
From source file:com.strandls.alchemy.webservices.client.ClientInitModule.java
/** * @return configuration for the client. */// w w w . j a va2 s.c om private Configuration getConfiguration() { final CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new PropertiesConfiguration(CLIENT_PROPERTIES)); } catch (final ConfigurationException e) { throw new RuntimeException(e); } return config; }
From source file:gda.configuration.properties.JakartaPropertiesConfig.java
/** * Remove all cached property information and reload system properties. User must reload any required property data * sources./*w ww .ja v a 2 s. co m*/ */ public void ResetProperties() { // clear out composite config and add a fresh system config into it config.clear(); Configuration sysConfig = new SystemConfiguration(); config.addConfiguration(sysConfig); // clear out the config map and put system into it configMap.clear(); configMap.put("system", sysConfig); }
From source file:com.opentable.config.ConfigFactory.java
private CombinedConfiguration loadNessStrategy() { // Allow foo/bar/baz and foo:bar:baz final String[] configNames = StringUtils.stripAll(StringUtils.split(configName, "/:")); final CombinedConfiguration cc = new CombinedConfiguration(new OverrideCombiner()); // All properties can be overridden by the System properties. cc.addConfiguration(new SystemConfiguration(), "systemProperties"); LOG.info("Configuration source: SYSTEM"); boolean loadedConfig = false; for (int i = 0; i < configNames.length; i++) { final String configFileName = configNames[configNames.length - i - 1]; final String configFilePath = StringUtils.join(configNames, "/", 0, configNames.length - i); try {// www .j ava 2 s . c o m final AbstractConfiguration subConfig = configStrategy.load(configFileName, configFilePath); if (subConfig == null) { throw new IllegalStateException( String.format("Configuration '%s' does not exist!", configFileName)); } else { cc.addConfiguration(subConfig, configFileName); LOG.info("Configuration source: {}", configFileName); loadedConfig = true; } } catch (ConfigurationException ce) { LOG.error(String.format("While loading configuration '%s'", configFileName), ce); } } if (!loadedConfig && configNames.length > 0) { throw new IllegalStateException(String.format( "Config name '%s' was given but no config file could be found, this looks fishy!", configName)); } return cc; }
From source file:com.strandls.alchemy.inject.AlchemyModuleFilterConfiguration.java
/** * @return configuration read from the config file. */// w ww. j a v a 2 s. co m private Configuration readConfiguration() { final CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); try { config.addConfiguration(new HierarchicalINIConfiguration(MODULE_CONFIGURATION_NAME)); } catch (final ConfigurationException e) { // ignore if the configuration file is missing. This means no // filtering intended. log.warn("Error loading configuration file {}", e); } return config; }
From source file:com.twitter.distributedlog.service.config.ServerConfiguration.java
public ServerConfiguration() { super(); addConfiguration(new SystemConfiguration()); }
From source file:fr.in2p3.cc.storage.treqs.tools.Configurator.java
/** * Constructor of the configurator where it defines the name of the * configuration file.//from ww w .ja v a 2 s. c om * * @throws ProblematicConfiguationFileException * If there is a problem reading the configuration file. */ private Configurator() throws ProblematicConfiguationFileException { LOGGER.trace("> Create instance"); this.properties = new CompositeConfiguration(); String name = null; this.properties.addConfiguration(new SystemConfiguration()); try { name = System.getProperty(Constants.CONFIGURATION_FILE); if (name == null) { name = DefaultProperties.CONFIGURATION_PROPERTIES; LOGGER.debug("No given file in System property"); } // TODO v2.0 Try to show the complete path of the configuration // file to use in a logger. This permits to know which is being used this.properties.addConfiguration(new HierarchicalINIConfiguration(name)); } catch (final ConfigurationException e) { throw new ProblematicConfiguationFileException(name, e); } LOGGER.trace("< Create instance"); }
From source file:edu.cornell.med.icb.goby.config.GobyConfiguration.java
/** * Load the Goby configuration.//w w w . j ava2 s . c o m * * @param defaultConfigFileLocations locations for configurations to check if one * was not explicitly defined in a system property. */ private GobyConfiguration(final String... defaultConfigFileLocations) { super(); configuration = new CompositeConfiguration(); // by loading the system configuration first, any values set on the java command line // with "-Dproperty.name=property.value" will take precedence configuration.addConfiguration(new SystemConfiguration()); // check to see if the user specified a configuration in the style of log4j if (configuration.containsKey("goby.configuration")) { final String configurationURLString = configuration.getString("goby.configuration"); try { if (LOG.isDebugEnabled()) { LOG.debug("Attempting to load " + configurationURLString); } final URL configurationURL = new URL(configurationURLString); configuration.addConfiguration(new PropertiesConfiguration(configurationURL)); LOG.info("Goby configured with " + configurationURL); } catch (MalformedURLException e) { LOG.error("Invalid Goby configuration", e); } catch (ConfigurationException e) { LOG.error("Could not configure Goby from " + configurationURLString, e); } } else { // no configuration file location specified so check the default locations for (final String configFile : defaultConfigFileLocations) { try { if (LOG.isDebugEnabled()) { LOG.debug("Attempting to load " + configFile); } configuration.addConfiguration(new PropertiesConfiguration(configFile)); } catch (ConfigurationException e) { continue; } // if we got here the file was loaded and we don't search any further LOG.info("Goby configured with " + new File(configFile).getAbsolutePath()); break; } } // load "default" configurations for any properties not found elsewhere // it's important that this be added LAST so the user can override any settings final Configuration defaultConfiguration = getDefaultConfiguration(); configuration.addConfiguration(defaultConfiguration); if (LOG.isDebugEnabled()) { LOG.debug("Goby configuration: "); final Iterator keys = configuration.getKeys(); while (keys.hasNext()) { final String key = (String) keys.next(); LOG.debug(key + " = " + configuration.getProperty(key)); } } }
From source file:com.github.blacklocus.rdsecho.EchoCfg.java
EchoCfg(String propertiesFilename) { this.cfg = new CompositeConfiguration(); this.cfg.addConfiguration(new SystemConfiguration()); try {// www . j a v a 2 s. c o m this.cfg.addConfiguration(new PropertiesConfiguration(propertiesFilename)); LOG.info("Reading configuration from {}", propertiesFilename); } catch (ConfigurationException e) { LOG.info("{} will not be read because {}", propertiesFilename, e.getMessage()); } validate(); }