List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:edu.si.services.sidora.rest.batch.BatchServiceTest.java
@Override protected String setConfigAdminInitialConfiguration(Properties configAdmin) { configAdmin.putAll(props); return "edu.si.sidora.batch"; }
From source file:com.twitter.ambrose.cascading.AmbroseCascadingNotifier.java
/** * The onStarting event is fired when a Flow instance receives the start() * message. -a Flow is cut down into executing units called stepFlow * -stepFlow contains a stepFlowJob which represents the mapreduce job to be * submitted to Hadoop -the DAG graph is constructed from the step graph * found in flow object// w w w. j a va 2s .co m * * @param flow */ @Override public void onStarting(Flow flow) { //init flow List<BaseFlowStep> steps = flow.getFlowSteps(); totalNumberOfJobs = steps.size(); currentFlowId = flow.getID(); Properties props = new Properties(); props.putAll(flow.getConfigAsProperties()); try { statsWriteService.initWriteService(props); } catch (IOException ioe) { throw new RuntimeException("Exception while initializing statsWriteService", ioe); } // convert the graph generated by cascading toDAGNodes Graph to be sent to ambrose AmbroseCascadingGraphConverter convertor = new AmbroseCascadingGraphConverter( (SimpleDirectedGraph) Flows.getStepGraphFrom(flow), dagNodeNameMap); convertor.convert(); AmbroseUtils.sendDagNodeNameMap(statsWriteService, currentFlowId, this.dagNodeNameMap); }
From source file:io.fabric8.agent.DownloadManagerTest.java
/** * Prepares DownloadManager to test/*from www . ja v a 2 s.c om*/ * * @param remoteRepo * @param settingsFile * @param props * @return * @throws IOException */ private DownloadManager createDownloadManager(String remoteRepo, String settingsFile, Properties props) throws IOException { File mavenSettings = new File(karafHome, settingsFile); Properties properties = new Properties(); if (props != null) { properties.putAll(props); } properties.setProperty("org.ops4j.pax.url.mvn.localRepository", systemRepoUri); properties.setProperty("org.ops4j.pax.url.mvn.repositories", remoteRepo); properties.setProperty("org.ops4j.pax.url.mvn.defaultRepositories", systemRepoUri); PropertiesPropertyResolver propertyResolver = new PropertiesPropertyResolver(properties); MavenConfigurationImpl mavenConfiguration = new MavenConfigurationImpl(propertyResolver, "org.ops4j.pax.url.mvn"); mavenConfiguration.setSettings(new MavenSettingsImpl(mavenSettings.toURI().toURL())); return new DownloadManager(mavenConfiguration, Executors.newSingleThreadExecutor()); }
From source file:org.sakaiproject.metaobj.utils.mvc.impl.LocalVelocityConfigurer.java
/** * Prepare the VelocityEngine instance and return it. * * @return the VelocityEngine instance/* ww w. j a va2s .c o m*/ * @throws java.io.IOException if the config file wasn't found * @throws org.apache.velocity.exception.VelocityException * on Velocity initialization failure */ public VelocityEngine createVelocityEngine() throws IOException, VelocityException { VelocityEngine velocityEngine = new VelocityEngine(); Properties props = new Properties(); // Merge local properties if set. if (!this.velocityProperties.isEmpty()) { props.putAll(this.velocityProperties); } // Apply properties to VelocityEngine. for (Iterator it = props.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); if (!(entry.getKey() instanceof String)) { throw new IllegalArgumentException( "Illegal property key [" + entry.getKey() + "]: only Strings allowed"); } velocityEngine.setProperty((String) entry.getKey(), entry.getValue()); } initResourceLoader(velocityEngine); try { // Perform actual initialization. velocityEngine.init(); } catch (IOException ex) { throw ex; } catch (VelocityException ex) { throw ex; } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { logger.error("Why does VelocityEngine throw a generic checked exception, after all?", ex); throw new VelocityException(ex.getMessage()); } return velocityEngine; }
From source file:com.krawler.notify.email.SimpleEmailSender.java
public synchronized Session createSession(EmailNotification notification) { Properties props = new Properties(defaults); Map<String, Object> customProps = notification.getCustomSetting(); if (customProps != null) { props.putAll(customProps); }/* ww w. j ava 2 s .com*/ return Session.getInstance(props, getAuthenticator(notification.getPasswordAuthentication())); }
From source file:org.apache.falcon.oozie.FeedExportCoordinatorBuilder.java
@Override public List<Properties> buildCoords(Cluster cluster, Path buildPath) throws FalconException { LOG.info("Generating Feed EXPORT coordinator."); org.apache.falcon.entity.v0.feed.Cluster feedCluster = FeedHelper.getCluster(entity, cluster.getName()); if (!FeedHelper.isExportEnabled(feedCluster)) { return null; }//from w ww . j a v a 2s . c o m if ((feedCluster.getValidity() != null) && (feedCluster.getValidity().getEnd().before(new Date()))) { LOG.warn("Feed IMPORT is not applicable as Feed's end time for cluster {} is not in the future", cluster.getName()); return null; } COORDINATORAPP coord = new COORDINATORAPP(); initializeCoordAttributes(coord, entity, cluster); Properties props = createCoordDefaultConfiguration(getEntityName()); initializeInputPath(coord, cluster, props); props.putAll(FeedHelper.getUserWorkflowProperties(getLifecycle())); WORKFLOW workflow = new WORKFLOW(); Path coordPath = getBuildPath(buildPath); Properties wfProp = OozieOrchestrationWorkflowBuilder.get(entity, cluster, Tag.EXPORT).build(cluster, coordPath); workflow.setAppPath(getStoragePath(wfProp.getProperty(OozieEntityBuilder.ENTITY_PATH))); props.putAll(wfProp); workflow.setConfiguration(getConfig(props)); ACTION action = new ACTION(); action.setWorkflow(workflow); coord.setAction(action); Path marshalPath = marshal(cluster, coord, coordPath); return Arrays.asList(getProperties(marshalPath, getEntityName())); }
From source file:org.hsweb.web.datasource.dynamic.DynamicDataSourceServiceImpl.java
protected javax.sql.DataSource createDataSource(DataSource dataSource) { AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean(); Properties xaProperties = new Properties(); if (dataSource.getProperties() != null) xaProperties.putAll(dataSource.getProperties()); if (dataSource.getDriver().contains("mysql")) { dataSourceBean.setXaDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"); xaProperties.put("pinGlobalTxToPhysicalConnection", true); xaProperties.put("user", dataSource.getUsername()); xaProperties.put("password", dataSource.getPassword()); xaProperties.put("url", dataSource.getUrl()); } else {// w ww . j ava 2 s .co m dataSourceBean.setXaDataSourceClassName(properties.getXa().getDataSourceClassName()); xaProperties.put("username", dataSource.getUsername()); xaProperties.put("password", dataSource.getPassword()); xaProperties.put("url", dataSource.getUrl()); xaProperties.put("driverClassName", dataSource.getDriver()); } dataSourceBean.setXaProperties(xaProperties); dataSourceBean.setUniqueResourceName("ds_" + dataSource.getId()); dataSourceBean.setMaxPoolSize(200); dataSourceBean.setMinPoolSize(5); dataSourceBean.setBorrowConnectionTimeout(60); boolean[] success = new boolean[1]; //? new Thread(() -> { try { dataSourceBean.init(); success[0] = true; } catch (AtomikosSQLException e) { closeDataSource(dataSourceBean); cache.remove(dataSource.getId()); } }).start(); //? new Thread(() -> { try { Thread.sleep(10000); if (!success[0]) { logger.error("?jdbc:{}", dataSourceBean); closeDataSource(dataSourceBean); cache.remove(dataSource.getId()); } } catch (Exception e) { } }).start(); return dataSourceBean; }
From source file:org.apache.falcon.oozie.FeedImportCoordinatorBuilder.java
@Override public List<Properties> buildCoords(Cluster cluster, Path buildPath) throws FalconException { org.apache.falcon.entity.v0.feed.Cluster feedCluster = FeedHelper.getCluster((Feed) entity, cluster.getName());// w ww.j a v a 2s. co m if (!FeedHelper.isImportEnabled(feedCluster)) { return null; } if (feedCluster.getValidity().getEnd().before(new Date())) { LOG.warn("Feed IMPORT is not applicable as Feed's end time for cluster {} is not in the future", cluster.getName()); return null; } COORDINATORAPP coord = new COORDINATORAPP(); initializeCoordAttributes(coord, (Feed) entity, cluster); Properties props = createCoordDefaultConfiguration(getEntityName()); initializeOutputPath(coord, cluster, props); props.putAll(FeedHelper.getUserWorkflowProperties(getLifecycle())); WORKFLOW workflow = new WORKFLOW(); Path coordPath = getBuildPath(buildPath); Properties wfProp = OozieOrchestrationWorkflowBuilder.get(entity, cluster, Tag.IMPORT).build(cluster, coordPath); workflow.setAppPath(getStoragePath(wfProp.getProperty(OozieEntityBuilder.ENTITY_PATH))); props.putAll(wfProp); workflow.setConfiguration(getConfig(props)); ACTION action = new ACTION(); action.setWorkflow(workflow); coord.setAction(action); Path marshalPath = marshal(cluster, coord, coordPath); return Arrays.asList(getProperties(marshalPath, getEntityName())); }
From source file:com.flipkart.aesop.runtime.relay.DefaultRelayFactory.java
/** * Interface method implementation. Creates and returns a {@link DefaultRelay} instance * @see org.springframework.beans.factory.FactoryBean#getObject() *//* ww w .j a v a 2s .c om*/ public DefaultRelay getObject() throws Exception { HttpRelay.Config config = new HttpRelay.Config(); ConfigLoader<HttpRelay.StaticConfig> staticConfigLoader = new ConfigLoader<HttpRelay.StaticConfig>( RelayConfig.RELAY_PROPERTIES_PREFIX, config); PhysicalSourceStaticConfig[] pStaticConfigs = new PhysicalSourceStaticConfig[this.producerRegistrationList .size()]; for (int i = 0; i < this.producerRegistrationList.size(); i++) { pStaticConfigs[i] = this.producerRegistrationList.get(i).getPhysicalSourceConfig().build(); // Register all sources with the static config for (LogicalSourceConfig logicalSourceConfig : this.producerRegistrationList.get(i) .getPhysicalSourceConfig().getSources()) { config.setSourceName(String.valueOf(logicalSourceConfig.getId()), logicalSourceConfig.getName()); } } //Making this a list to initialise each producer seperately with initial SCN HttpRelay.StaticConfig[] staticConfigList = new HttpRelay.StaticConfig[this.producerRegistrationList .size()]; DefaultRelay relay = null; FileSystemSchemaRegistryService.Config configBuilder = new FileSystemSchemaRegistryService.Config(); configBuilder.setFallbackToResources(true); configBuilder.setSchemaDir(this.getRelayConfig().getSchemaRegistryLocation()); FileSystemSchemaRegistryService.StaticConfig schemaRegistryServiceConfig = configBuilder.build(); FileSystemSchemaRegistryService schemaRegistryService = FileSystemSchemaRegistryService .build(schemaRegistryServiceConfig); if (this.maxScnReaderWriters == null) { this.maxScnReaderWriters = new HashMap<String, MultiServerSequenceNumberHandler>(); for (int i = 0; i < this.producerRegistrationList.size(); i++) { //Get Properties from Relay Config Properties mergedProperties = new Properties(); mergedProperties.putAll(this.relayConfig.getRelayProperties()); // Obtain Properties from Product Registration if it exists if (producerRegistrationList.get(i).getProperties() != null) { mergedProperties.putAll(producerRegistrationList.get(i).getProperties()); } //Loading a list of static configs staticConfigList[i] = staticConfigLoader.loadConfig(mergedProperties); //Making a handlerFactory per producer. SequenceNumberHandlerFactory handlerFactory = staticConfigList[i].getDataSources() .getSequenceNumbersHandler().createFactory(); this.maxScnReaderWriters.put( this.producerRegistrationList.get(i).getPhysicalSourceConfig().getName(), new MultiServerSequenceNumberHandler(handlerFactory)); } } //Initialising relay. Only passing the first static config as everything else apart from // initial SCN per producer is the same. Initial SCN per producer has already been set relay = new DefaultRelay(staticConfigList[0], pStaticConfigs, SourceIdNameRegistry.createFromIdNamePairs(staticConfigList[0].getSourceIds()), schemaRegistryService); //Commenting out this line. The {@link #getMaxScnReaderWriters() getMaxScnReaderWriters} is not used anywhere. //relay.setMaxScnReaderWriters(this.maxScnReaderWriters.get(this.producerRegistrationList.get(0))); // now set all the Relay initialized services on the producers, if they are of type AbstractEventProducer for (int i = 0; i < this.producerRegistrationList.size(); i++) { ProducerRegistration producerRegistration = this.producerRegistrationList.get(i); PhysicalSourceStaticConfig pStaticConfig = pStaticConfigs[i]; if (AbstractEventProducer.class.isAssignableFrom(producerRegistration.getEventProducer().getClass())) { AbstractEventProducer producer = (AbstractEventProducer) producerRegistration.getEventProducer(); DbusEventBufferAppendable eb = relay.getEventBuffer() .getDbusEventBufferAppendable(pStaticConfig.getSources()[0].getId()); producer.setEventBuffer( new ProducerEventBuffer(producer.getName(), eb, relay.getMetricsCollector())); // here we assume single event buffer is shared among all logical sources //Setting the maxScnReaderWriter per producer as initialised above. producer.setMaxScnReaderWriter( this.maxScnReaderWriters.get(producerRegistration.getPhysicalSourceConfig().getName()) .getOrCreateHandler(pStaticConfig.getPhysicalPartition())); producer.setSchemaRegistryService(relay.getSchemaRegistryService()); producer.setDbusEventsStatisticsCollector(relay.getInboundEventStatisticsCollector()); } } // set the ProducerRegistration instances on the Relay relay.setProducerRegistrationList(this.producerRegistrationList); return relay; }
From source file:com.enonic.cms.core.localization.LocalizationResourceBundleServiceImpl.java
private LocalizationResourceBundle createResourceBundle(final Locale locale, final ResourceKey defaultLocalizationResourceKey) { Properties props = new Properties(); String lang = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); props.putAll(loadBundle(defaultLocalizationResourceKey, "")); if (StringUtils.isNotEmpty(lang)) { lang = lang.toLowerCase();//from www . j a va 2 s . c om props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang)); } if (StringUtils.isNotEmpty(country)) { country = country.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country)); } if (StringUtils.isNotEmpty(variant)) { variant = variant.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country + "_" + variant)); } return new LocalizationResourceBundle(props); }