本文整理匯總了Java中org.apache.commons.configuration.CompositeConfiguration.addConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java CompositeConfiguration.addConfiguration方法的具體用法?Java CompositeConfiguration.addConfiguration怎麽用?Java CompositeConfiguration.addConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.configuration.CompositeConfiguration
的用法示例。
在下文中一共展示了CompositeConfiguration.addConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: renderWithPrettyUrls
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
@Test
public void renderWithPrettyUrls() throws Exception {
Map<String, Object> testProperties = new HashMap<String, Object>();
testProperties.put(Keys.URI_NO_EXTENSION, true);
testProperties.put(Keys.URI_NO_EXTENSION_PREFIX, "/blog");
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new MapConfiguration(testProperties));
config.addConfiguration(ConfigUtil.load(new File(this.getClass().getResource("/").getFile())));
Crawler crawler = new Crawler(db, sourceFolder, config);
crawler.crawl(new File(sourceFolder.getPath() + File.separator + config.getString(Keys.CONTENT_FOLDER)));
Assert.assertEquals(4, db.getDocumentCount("post"));
Assert.assertEquals(3, db.getDocumentCount("page"));
DocumentList documents = db.getPublishedPosts();
for (Map<String, Object> model : documents) {
String noExtensionUri = "blog/\\d{4}/" + FilenameUtils.getBaseName((String) model.get("file")) + "/";
Assert.assertThat(model.get("noExtensionUri"), RegexMatcher.matches(noExtensionUri));
Assert.assertThat(model.get("uri"), RegexMatcher.matches(noExtensionUri + "index\\.html"));
}
}
示例2: createConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
protected CompositeConfiguration createConfiguration() throws ConfigurationException {
final CompositeConfiguration config = new CompositeConfiguration();
if (properties != null) {
config.addConfiguration(new MapConfiguration(properties));
}
config.addConfiguration(new MapConfiguration(project.getProperties()));
config.addConfiguration(ConfigUtil.load(inputDirectory));
if (getLog().isDebugEnabled()) {
getLog().debug("Configuration:");
Iterator<String> iter = config.getKeys();
while (iter.hasNext()) {
String key = iter.next();
getLog().debug(key + ": " + config.getString(key));
}
}
return config;
}
示例3: getCommonConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public Configuration getCommonConfiguration() throws IOException {
CompositeConfiguration conf = new CompositeConfiguration();
Enumeration<URL> resources = SAMLConfiguration.class.getClassLoader().getResources("oiosaml-common.properties");
while (resources.hasMoreElements()) {
URL u = resources.nextElement();
log.debug("Loading config from " + u);
try {
conf.addConfiguration(new PropertiesConfiguration(u));
} catch (ConfigurationException e) {
log.error("Cannot load the configuration file", e);
throw new WrappedException(Layer.DATAACCESS, e);
}
}
return conf;
}
示例4: getCommonConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public Configuration getCommonConfiguration() throws IOException {
CompositeConfiguration conf = new CompositeConfiguration();
Enumeration<URL> resources = SAMLConfiguration.class.getClassLoader().getResources("oiosaml-common.properties");
while (resources.hasMoreElements()) {
URL u = resources.nextElement();
log.debug("Loading config from " + u);
try {
conf.addConfiguration(new PropertiesConfiguration(u));
} catch (ConfigurationException e) {
log.error("Cannot load the configuration file", e);
throw new WrappedException(Layer.DATAACCESS, e);
}
}
return conf;
}
示例5: createConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的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;
}
示例6: getConfig
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
/**
* The combined config = current user config + defaults for non-specified properties.
* TODO: instead of re-reading user config every time, it would be better
* to set up Commons Configuration listeners on the userfile.
* @return even if reading user config fails, will return default config
*/
public CompositeConfiguration getConfig() {
// try loading user config
FileConfiguration userConfig = null;
try {
userConfig = BmConfig.forClass(BaseMap2D.class);
} catch (ConfigurationException | IOException ex) {
Exceptions.printStackTrace(ex);
}
CompositeConfiguration compositeConfig = new CompositeConfiguration();
// the order of adding configurations to combined configuration is important
// whoever is added first "shadows" the same key in all subsequently added
// configuraions. Thus, add the DEFAULTs at the very end
if (userConfig != null) {
compositeConfig.addConfiguration(userConfig);
}
compositeConfig.addConfiguration(defaultConfig);
return compositeConfig;
}
示例7: getConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static Configuration getConfiguration(Session pSession) {
try {
PropertiesConfiguration prop = new PropertiesConfiguration();
for(Object aKey : pSession.getProperties().keySet()) {
Object aValue = pSession.getProperties().get(aKey);
prop.addProperty(aKey.toString(), aValue);
}
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(prop);
URL lURL = Thread.currentThread().getContextClassLoader().getResource("javamail-ews-bridge.default.properties");
config.addConfiguration(new PropertiesConfiguration(lURL));
return config;
} catch (ConfigurationException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例8: main
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) throws ConfigurationException {
log.setLevel(Level.DEBUG);
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(new PropertiesConfiguration("kafka.properties"));
conf.addConfiguration(new PropertiesConfiguration("cassandra.properties"));
conf.addConfiguration(new PropertiesConfiguration("spark.properties"));
conf.addConfiguration(new PropertiesConfiguration("es.properties"));
// Path filePath = Paths.get("/media/sf_Download/ipinyou/new");
// Path filePath = Paths.get("/media/sf_Download/data/iPinYou/ipinyou.contest.dataset_unpacked/training2nd/data");
// Path filePath = Paths.get("/media/sf_Download/data/mors/new");
Path filePath = Paths.get("/media/sf_Download/data/mors/cassandra_test"); // Cassandra TEST
String esIdxSuffix = "log_%s/bid";
BiddingLogWorkflow wf = new BiddingLogWorkflow();
try {
wf.runBatch(conf, filePath, esIdxSuffix);
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: main
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) throws ConfigurationException {
PredictionFlow workflow = new PredictionFlow();
log.setLevel(Level.DEBUG);
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(new PropertiesConfiguration("kafka.properties"));
conf.addConfiguration(new PropertiesConfiguration("spark.properties"));
conf.addConfiguration(new PropertiesConfiguration("cassandra.properties"));
conf.addConfiguration(new PropertiesConfiguration("es.properties"));
try {
workflow.run(conf);
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: main
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) throws ConfigurationException {
StreamingUserTypeClassification workflow = new StreamingUserTypeClassification();
log.setLevel(Level.DEBUG);
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(new PropertiesConfiguration("kafka.properties"));
conf.addConfiguration(new PropertiesConfiguration("spark.properties"));
conf.addConfiguration(new PropertiesConfiguration("es.properties"));
try {
workflow.run(conf);
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: main
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) throws ConfigurationException {
KafkaSparkCassandraFlow workflow = new KafkaSparkCassandraFlow();
log.setLevel(Level.DEBUG);
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(new PropertiesConfiguration("kafka.properties"));
conf.addConfiguration(new PropertiesConfiguration("spark.properties"));
conf.addConfiguration(new PropertiesConfiguration("cassandra.properties"));
try {
workflow.run(conf);
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: main
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) throws ConfigurationException {
KafkaSparkEsFlow workflow = new KafkaSparkEsFlow();
log.setLevel(Level.DEBUG);
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(new PropertiesConfiguration("kafka.properties"));
conf.addConfiguration(new PropertiesConfiguration("spark.properties"));
conf.addConfiguration(new PropertiesConfiguration("es.properties"));
try {
workflow.run(conf);
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: ArchaiusInitializingBeanPostProcessor
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
public ArchaiusInitializingBeanPostProcessor(ConfigurableApplicationContext applicationContext, AbstractPollingScheduler pollingScheduler, SpringEnvironmentPolledConfigurationSource polledConfigurationSource, List<ClasspathPropertySource> propertyBindings) {
this.applicationContext = Objects.requireNonNull(applicationContext, "applicationContext");
this.pollingScheduler = Objects.requireNonNull(pollingScheduler, "pollingScheduler");
this.polledConfigurationSource = Objects.requireNonNull(polledConfigurationSource, "polledConfigurationSource");
this.propertyBindings = propertyBindings != null ? propertyBindings : Collections.emptyList();
initPropertyBindings();
configurationInstance = new DynamicConfiguration(polledConfigurationSource, pollingScheduler);
if (!ConfigurationManager.isConfigurationInstalled()) {
ConfigurationManager.install(new CompositeConfiguration());
}
CompositeConfiguration config = (CompositeConfiguration) ConfigurationManager.getConfigInstance();
config.addConfiguration(configurationInstance);
applicationContext.getBeanFactory().registerSingleton("environmentBackedConfig", ConfigurationManager.getConfigInstance());
applicationContext.getBeanFactory().registerAlias("environmentBackedConfig", "abstractConfiguration");
}
示例14: testConfigLoadingInValidMissingDelay
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
/**
* Failure Testing:
*
* Test that missing delay fails.
* If we have no delay then we do not pick a default. So a Configuration
* Exception is thrown.
*
* */
public void testConfigLoadingInValidMissingDelay()
{
SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();
XMLConfiguration xmlconfig = new XMLConfiguration();
xmlconfig.addProperty("timeunit", TimeUnit.SECONDS.toString());
// Create a CompositeConfiguration as this is what the broker uses
CompositeConfiguration composite = new CompositeConfiguration();
composite.addConfiguration(xmlconfig);
try
{
config.setConfiguration("", composite);
fail("Configuration should fail to validate");
}
catch (ConfigurationException e)
{
assertEquals("Incorrect message.", "SlowConsumerDetectionConfiguration: unable to configure invalid delay:null", e.getMessage());
}
}
示例15: setConfiguration
import org.apache.commons.configuration.CompositeConfiguration; //導入方法依賴的package包/類
/**
* Apply the given configuration to this VirtualHostConfiguration
*
* @param config
* the config to apply
* @throws ConfigurationException
* if a problem occurs with configuration
*/
public void setConfiguration(Configuration config) throws ConfigurationException {
setConfiguration("virtualhosts.virtualhost", config);
Iterator i = getListValue("queues.queue.name").iterator();
while (i.hasNext()) {
String queueName = (String) i.next();
_queues.put(queueName, new QueueConfiguration(queueName, this));
}
i = getListValue("exchanges.exchange.name").iterator();
int count = 0;
while (i.hasNext()) {
CompositeConfiguration mungedConf = new CompositeConfiguration();
mungedConf.addConfiguration(config.subset("exchanges.exchange(" + count++ + ")"));
mungedConf.addConfiguration(_configuration.subset("exchanges"));
String exchName = (String) i.next();
_exchanges.put(exchName, new ExchangeConfiguration(exchName, mungedConf));
}
}