List of usage examples for org.apache.commons.configuration SystemConfiguration SystemConfiguration
public SystemConfiguration()
From source file:org.nuxeo.ecm.platform.configuration.ConfigurationServiceImpl.java
@Override public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) throws Exception { if (CONFIGURATION_EP.equals(extensionPoint) && contribution instanceof ConfigurationDescriptor) { log.debug("Registering contribution..."); ConfigurationDescriptor desc = (ConfigurationDescriptor) contribution; String name = desc.getName(); String type = desc.getType(); if (ConfigurationConstants.TYPE_SYSTEM.equals(type)) { log.debug("Using system properties"); SystemConfiguration conf = new SystemConfiguration(); configurations.put(name, conf); } else if (ConfigurationConstants.TYPE_PROPERTIES.equals(type)) { String path = Framework.expandVars(desc.getFile()); log.debug("Using properties file: " + path); PropertiesConfiguration conf = new PropertiesConfiguration(path); conf.setAutoSave(true);//from w w w. ja v a 2s . com configurations.put(name, conf); } else if (ConfigurationConstants.TYPE_DATABASE.equals(type)) { String ns = desc.getDbnamespace(); log.debug("Using database namespace: " + ns); DataSource dataSource = DataSourceHelper.getDataSource(ConfigurationConstants.DATASOURCE); DatabaseConfiguration conf = new DatabaseConfiguration(dataSource, ConfigurationConstants.TABLE, ConfigurationConstants.COL_NAMESPACE, ConfigurationConstants.COL_KEY, ConfigurationConstants.COL_VALUE, ns); configurations.put(name, conf); } else { log.warn("Unsuported type: " + type + ", skipping contribution."); return; } if (names.contains(name)) { log.warn("Overriding existing configuration: " + name); } names.add(name); log.info("Contribution " + name + " registered."); } }
From source file:org.overlord.sramp.ui.server.listeners.Initializer.java
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) *///from www . ja v a2 s.co m @Override public void contextInitialized(ServletContextEvent event) { try { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); config.addConfiguration(new JNDIConfiguration("java:comp/env/overlord/s-ramp-ui")); config.addConfiguration(new PropertiesConfiguration( Initializer.class.getResource("/META-INF/config/org.overlord.sramp.ui.server.api.properties"))); System.out.println("S-RAMP user interface configuration loaded. S-RAMP Atom API endpoint: " + config.getString("s-ramp.atom-api.endpoint")); // Now initialize the S-RAMP Atom API Client singleton SrampAtomApiClient.init(config); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.qucosa.migration.Main.java
public static void main(String[] args) { CommandLineOptions options = new CommandLineOptions(args); System.setProperty("sword.noop", String.valueOf(options.isNoop())); System.setProperty("sword.slugheader", String.valueOf(options.useSlugHeader())); System.setProperty("sword.purge", String.valueOf(options.purgeBeforeDeposit())); System.setProperty("sword.collection", String.valueOf(options.getCollection())); if (options.getOwnerId() != null) { System.setProperty("sword.ownerID", options.getOwnerId()); }/* w w w .j av a 2 s. c o m*/ MigrationContext ctx = null; try { Boolean hasStagingResource = (options.getStageResource() != null); Boolean hasStagingresourceFile = (!options.getIdFile().isEmpty()); Boolean hasTransformResource = (options.getTransformResource() != null); Boolean isTransforming = hasTransformResource || (options.getMappings().length > 0) || (options.isStageTransform()); Boolean isStaging = hasStagingResource || hasStagingresourceFile; System.setProperty("transforming", String.valueOf(isTransforming)); Configuration conf = new SystemConfiguration(); ctx = new MigrationContext(conf, isStaging, isTransforming); ctx.start(); final String routingSlip = buildTransformationRoutingSlip(options); if (hasStagingResource) { sendExchange("direct:staging", options.getStageResource(), ctx, routingSlip); } if (hasStagingresourceFile) { sendExchange("direct:staging:file", options.getIdFile(), ctx, routingSlip); } if (hasTransformResource) { sendExchange("direct:transform", options.getTransformResource(), ctx, routingSlip); } } catch (Exception e) { log.error(e.getMessage(), e); exit(1); } finally { if (ctx != null) try { ctx.stop(); } catch (Exception e) { System.out.println("Error shutting down Camel: " + e.getMessage()); e.printStackTrace(); exit(1); } } }
From source file:org.qucosa.opus.OpusRepositoryIT.java
@Before public void setUp() throws ConfigurationException, SQLException { Configuration conf = new SystemConfiguration(); opus4Repository = new Opus4ImmutableRepository(); opus4Repository.configure(conf);//from ww w . j av a 2 s. c om }
From source file:org.soaplab.clients.ClientConfig.java
/************************************************************************** * The main method returning a configuration object. The returned * object is a singleton - but its contents (the properties it * carries) can be changed dynamically (the properties are * reloaded if their files are modified). <p> * * The configuration object contains all Java system properties * and properties read from the Soaplab client configuration * file. This file name is given by the system property {@link * #PROP_SOAPLAB_CLIENT_CONFIGURATION}, or using a default name * {@link #SOAPLAB_CLIENT_CONFIG_FILENAME}. If the filename does * not specify an absolute path, the file will be searched * automatically in the following locations: * * <ul>/* w ww . j ava 2 s. c om*/ * <li> in the current directory, * <li> in the user home, * <li> directory in the classpath * </ul><p> * * The System properties take precedence over properties read from * the Soaplab client property file. <p> * * @return a configuration object **************************************************************************/ public static synchronized CompositeConfiguration get() { if (config == null) { // set the global configuration CompositeConfiguration cfg = new CompositeConfiguration(); // first, add System properties cfg.addConfiguration(new SystemConfiguration()); // second, add Soaplab client properties file(s) String[] configFilenames = cfg.getStringArray(PROP_SOAPLAB_CLIENT_CONFIGURATION); if (configFilenames == null || configFilenames.length == 0) configFilenames = new String[] { SOAPLAB_CLIENT_CONFIG_FILENAME }; for (int i = 0; i < configFilenames.length; i++) { log.info("Using configuration file: " + configFilenames[i]); addPropertiesConfiguration(cfg, configFilenames[i]); } // keep it for other calls config = cfg; } return config; }
From source file:org.soaplab.services.Config.java
/************************************************************************** * The main method returning a configuration object. The returned * object is a singleton - but its contents (the properties it * carries) can be changed dynamically (the properties are * reloaded if their files are modified). <p> * * The configuration object contains all Java system properties * and properties read from the Soaplab configuration file. This * file name is given by the system property {@link * #PROP_SOAPLAB_CONFIGURATION}, or using a default name {@link * #SOAPLAB_CONFIG_FILENAME}. If the filename does not specify an * absolute path, the file will be searched automatically in the * following locations://from ww w .j a v a 2 s . c om * * <ul> * <li> in the current directory, * <li> in the user home, * <li> directory in the classpath * </ul><p> * * The System properties take precedence over properties read from * the Soaplab property file. <p> * * The configuration object can be anytime extended by properties * from other sources by using either methods defined in the * <tt>CompositeConfiguration</tt>'s API, or using a convenient * methods {@link #addConfigPropertyFile} and {@link * #addConfigXMLFile} defined here. Properties from these * additional files have higher priority than properties added * earlier - except System properties, they are always the most * prioritized. <p> * * @return a configuration object **************************************************************************/ public static synchronized CompositeConfiguration get() { if (config == null) { // set the Soaplab global configuration CompositeConfiguration cfg = new CompositeConfiguration(); // first, add System properties cfg.addConfiguration(new SystemConfiguration()); // second, add Soaplab properties file(s) String[] configFilenames = cfg.getStringArray(PROP_SOAPLAB_CONFIGURATION); if (configFilenames == null || configFilenames.length == 0) configFilenames = new String[] { SOAPLAB_CONFIG_FILENAME }; for (int i = 0; i < configFilenames.length; i++) { log.info("Using configuration file: " + configFilenames[i]); addPropertiesConfiguration(cfg, configFilenames[i]); } // keep it for other calls config = cfg; } return config; }
From source file:org.sonar.ant.Launcher.java
private Configuration getInitialConfiguration(ProjectDefinition project) { CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); configuration.addConfiguration(new MapConfiguration(project.getProperties())); return configuration; }
From source file:org.sonar.batch.MavenProjectBuilder.java
Configuration getStartupConfiguration(MavenProject pom) { CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); configuration.addConfiguration(new MapConfiguration(pom.getModel().getProperties())); return configuration; }
From source file:org.sonar.batch.ProjectConfiguration.java
private void loadSystemSettings() { addConfiguration(new SystemConfiguration()); addConfiguration(new EnvironmentConfiguration()); }
From source file:org.sonar.maven.SonarMojo.java
private Configuration getInitialConfiguration() { CompositeConfiguration configuration = new CompositeConfiguration(); configuration.addConfiguration(new SystemConfiguration()); configuration.addConfiguration(new EnvironmentConfiguration()); configuration.addConfiguration(new MapConfiguration(project.getModel().getProperties())); return configuration; }