List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:org.candlepin.config.EncryptedValueConfigurationParser.java
public Properties parseConfig(Map<String, String> inputConfiguration) { // pull out properties that we know might be crypted passwds // unencrypt them, and update the properties with the new versions // do this here so DbBasicAuthConfigParser and JPAConfigParser // will do it. Split it to a sub method so sub classes can // provide there own implementation of crypt/decrypt ///*w ww. j a v a 2s .co m*/ Properties toReturn = new Properties(); Properties toDecrypt = stripPrefixFromConfigKeys(inputConfiguration); toReturn.putAll(toDecrypt); if (encryptedConfigKeys() != null) { for (String encConfigKey : encryptedConfigKeys()) { String passwordString = toDecrypt.getProperty(encConfigKey); if (passwordString != null) { String deCryptedValue = decryptValue(passwordString, getPassphrase()); toReturn.setProperty(encConfigKey, deCryptedValue); } } } return toReturn; }
From source file:org.jnap.core.email.EmailSender.java
public void send(Email email) { EmailAccountInfo accountInfo = defaultEmailAccount; JavaMailSenderImpl sender = this.defaultMailSender; if (email.getAccountInfo() != null) { accountInfo = email.getAccountInfo(); synchronized (this.mailSenderMap) { sender = this.mailSenderMap.get(accountInfo); if (sender == null) { sender = new JavaMailSenderImpl(); Properties props = new Properties(this.defaultEmailAccount.getJavaMailProperties()); props.putAll(accountInfo.getJavaMailProperties()); sender.setJavaMailProperties(props); sender.setUsername(accountInfo.getUsername()); sender.setPassword(accountInfo.getPassword()); this.mailSenderMap.put(accountInfo, sender); }//from w w w . j ava2 s .c o m } } else { email.setAccountInfo(accountInfo); } sender.send((MimeMessagePreparator) email); }
From source file:es.csic.iiia.planes.cli.Cli.java
/** * Parse the provided list of arguments according to the program's options. * /*www .ja v a 2 s. c o m*/ * @param in_args * list of input arguments. * @return a configuration object set according to the input options. */ private static Configuration parseOptions(String[] in_args) { CommandLineParser parser = new PosixParser(); CommandLine line = null; Properties settings = loadDefaultSettings(); try { line = parser.parse(options, in_args); } catch (ParseException ex) { Logger.getLogger(Cli.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); showHelp(); } if (line.hasOption('h')) { showHelp(); } if (line.hasOption('d')) { dumpSettings(); } if (line.hasOption('s')) { String fname = line.getOptionValue('s'); try { settings.load(new FileReader(fname)); } catch (IOException ex) { throw new IllegalArgumentException("Unable to load the settings file \"" + fname + "\""); } } // Apply overrides settings.setProperty("gui", String.valueOf(line.hasOption('g'))); settings.setProperty("quiet", String.valueOf(line.hasOption('q'))); Properties overrides = line.getOptionProperties("o"); settings.putAll(overrides); String[] args = line.getArgs(); if (args.length < 1) { showHelp(); } settings.setProperty("problem", args[0]); Configuration c = new Configuration(settings); System.out.println(c.toString()); /** * Modified by Guillermo B. Print settings to a result file, titled * "results.txt" */ try { FileWriter fw = new FileWriter("results.txt", true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new PrintWriter(bw); String[] results = c.toString().split("\n"); // out.println(results[8]); for (String s : results) { out.println(s); } // out.println(results[2]); // out.println(results[8]); out.close(); } catch (IOException e) { } /** * Modified by Ebtesam Save settings to a .csv file, titled * "resultsCSV.csv" */ try { FileWriter writer = new FileWriter("resultsCSV.csv", true); FileReader reader = new FileReader("resultsCSV.csv"); String header = "SAR Strategy,# of Searcher UAVs,# of Survivors," + "# of Survivors rescued,Min.Time needed to rescue Survivors,Mean. Time needed to rescue Survivors,Max. Time needed to rescue Survivors," + "# of Survivors found,Min. Time needed to find Survivors,Mean Time needed to find Survivors,Max. Time needed to find Survivors," + "Running Time of Simulation\n"; if (reader.read() == -1) { writer.append(header); writer.append("\n"); } reader.close(); String[] results = c.toString().split("\n"); writer.append(results[2].substring(10)); writer.append(","); writer.append(results[20].substring(11)); writer.append(","); writer.append(results[30].substring(18)); writer.write(","); writer.close(); } catch (IOException e) { } if (line.hasOption('t')) { System.exit(0); } return c; }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBean.java
private Properties doGetObject() { final Properties result = new Properties(); MatchCallback callback = new MatchCallback() { @Override/*from ww w . j ava 2 s. c o m*/ public void process(Properties properties, Map<String, Object> map) { result.putAll(properties); } }; process(callback); return result; }
From source file:de.innovationgate.webgate.api.jdbc.pool.DBCPReplicationConnectionProvider.java
public void configure(Map propsMap) throws HibernateException { try {/*from ww w . j a va2 s .co m*/ log.info("Configure DBCPReplicationConnectionProvider"); Properties props = new Properties(); props.putAll(propsMap); String jdbcUrl = props.getProperty(Environment.URL); // split jdbcURL by "|" and configure masterDS for first and slaveDataSources for all other URLs _jdbcUrls = jdbcUrl.split("\\|"); // spec. configuration for dbcp if (!props.containsKey("hibernate.connection.connectTimeout")) { props.setProperty("hibernate.dbcp.poolPreparedStatements", "true"); } if (!props.containsKey("hibernate.connection.connectTimeout")) { props.setProperty("hibernate.connection.connectTimeout", "5000"); } if (!props.containsKey("hibernate.connection.socketTimeout")) { props.setProperty("hibernate.connection.socketTimeout", "20000"); } if (!props.containsKey("hibernate.dbcp.testOnBorrow")) { props.setProperty("hibernate.dbcp.testOnBorrow", "true"); } if (!props.containsKey("hibernate.dbcp.validationQuery")) { props.setProperty("hibernate.dbcp.validationQuery", "select 1"); } // create master DS log.info("configuring master datasource on url: " + _jdbcUrls[0]); Properties masterProps = (Properties) props.clone(); masterProps.setProperty(Environment.URL, _jdbcUrls[0]); DBCPConnectionProvider masterProvider = new DBCPConnectionProvider(); masterProvider.configure(masterProps); _masterDS = masterProvider.getDs(); // create slave datasources for (int i = 1; i < _jdbcUrls.length; i++) { log.info("configuring slave datasource on url: " + _jdbcUrls[i]); Properties slaveProps = (Properties) props.clone(); slaveProps.setProperty(Environment.URL, _jdbcUrls[i]); DBCPConnectionProvider slaveProvider = new DBCPConnectionProvider(); slaveProvider.configure(slaveProps); _slaveDSList.add(slaveProvider.getDs()); } log.info("Configure DBCPReplicationConnectionProvider complete"); } catch (Exception e) { log.fatal("Could not create DBCPReplicationConnectionProvider.", e); throw new HibernateException("Could not create DBCPReplicationConnectionProvider.", e); } }
From source file:ome.client.utests.Preferences3Test.java
@Test(groups = "ticket:1058") public void testOmeroUserIsProperlySetWithSpring2_5_5Direct() { Server s = new Server("localhost", 1099); Login l = new Login("me", "password"); Properties pl = l.asProperties(); pl.setProperty("test.system.value", "This is like omero.user without local.properties"); Properties ps = s.asProperties(); ps.putAll(pl); OmeroContext c = OmeroContext.getContext(ps, "ome.client.test2"); c.getBean("list"); }
From source file:com.googlecode.t7mp.steps.CopyUserConfigStep.java
private void mergeUserCatalinaPropertiesWithDefault(File userCatlinaPropertiesFile) throws IOException { File defaultConfigFile = new File(catalinaBaseDir, "/conf/catalina.properties"); Properties userCatalinaProperties = loadPropertiesFromFile(userCatlinaPropertiesFile); Properties defaultCatalinProperties = loadPropertiesFromFile(defaultConfigFile); mergeProperties(defaultCatalinProperties, userCatalinaProperties, getExcludes()); defaultCatalinProperties.putAll(this.configuration.getSystemProperties()); writePropertiesToFile(defaultCatalinProperties, defaultConfigFile); }
From source file:org.lightmare.jpa.spring.SpringORM.java
/** * Initializes data source name from properties *//*from w ww .java 2 s .c o m*/ private void initDataSourceName() { if (dataSourceName == null || dataSourceName.isEmpty()) { Properties nameProperties = new Properties(); nameProperties.putAll(properties); dataSourceName = nameProperties.getProperty(ConfigKeys.SPRING_DS_NAME_KEY.key); properties.remove(ConfigKeys.SPRING_DS_NAME_KEY.key); } }
From source file:ai.grakn.engine.controller.SystemController.java
@GET @Path("/configuration") @ApiOperation(value = "Get config which is used to build graphs") @ApiImplicitParam(name = "graphConfig", value = "The type of graph config to return", required = true, dataType = "string", paramType = "path") private String getConfiguration(Request request, Response response) { String graphConfig = request.queryParams(GRAPH_CONFIG_PARAM); // Make a copy of the properties object Properties properties = new Properties(); properties.putAll(factory.properties()); // Get the correct factory based on the request switch ((graphConfig != null) ? graphConfig : DEFAULT) { case DEFAULT: break; // Factory is already correctly set case COMPUTER: properties.setProperty(FACTORY_INTERNAL, properties.get(FACTORY_ANALYTICS).toString()); break;//from w w w .ja v a 2s . c om default: throw GraknServerException.internalError("Unrecognised graph config: " + graphConfig); } // Turn the properties into a Json object Json config = Json.make(properties); // Remove the JWT Secret if (config.has(GraknEngineConfig.JWT_SECRET_PROPERTY)) { config.delAt(GraknEngineConfig.JWT_SECRET_PROPERTY); } return config.toString(); }
From source file:org.musicrecital.dao.spring.HibernateExtensionPostProcessor.java
/** * Adds the annotated classes and the mapping resources to the existing Session Factory configuration. * @param configurableListableBeanFactory the good ol' bean factory */// w ww . j a v a 2s . co m @SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) { if (configurableListableBeanFactory.containsBean(sessionFactoryBeanName)) { BeanDefinition sessionFactoryBeanDefinition = configurableListableBeanFactory .getBeanDefinition(sessionFactoryBeanName); MutablePropertyValues propertyValues = sessionFactoryBeanDefinition.getPropertyValues(); if (mappingResources != null) { // do we have existing resourses? PropertyValue propertyValue = propertyValues.getPropertyValue("mappingResources"); if (propertyValue == null) { propertyValue = new PropertyValue("mappingResources", new ArrayList()); propertyValues.addPropertyValue(propertyValue); } // value is expected to be a list. List existingMappingResources = (List) propertyValue.getValue(); existingMappingResources.addAll(mappingResources); } if (annotatedClasses != null) { // do we have existing resources? PropertyValue propertyValue = propertyValues.getPropertyValue("annotatedClasses"); if (propertyValue == null) { propertyValue = new PropertyValue("annotatedClasses", new ArrayList()); propertyValues.addPropertyValue(propertyValue); } // value is expected to be a list. List existingMappingResources = (List) propertyValue.getValue(); existingMappingResources.addAll(annotatedClasses); } if (configLocations != null) { PropertyValue propertyValue = propertyValues.getPropertyValue("configLocations"); if (propertyValue == null) { propertyValue = new PropertyValue("configLocations", new ArrayList()); propertyValues.addPropertyValue(propertyValue); } List existingConfigLocations = (List) propertyValue.getValue(); existingConfigLocations.addAll(configLocations); } if (hibernateProperties != null) { PropertyValue propertyValue = propertyValues.getPropertyValue("hibernateProperties"); if (propertyValue == null) { propertyValue = new PropertyValue("hibernateProperties", new Properties()); propertyValues.addPropertyValue(propertyValue); } Properties existingHibernateProperties = (Properties) propertyValue.getValue(); existingHibernateProperties.putAll(hibernateProperties); } } else { throw new NoSuchBeanDefinitionException( "No bean named [" + sessionFactoryBeanName + "] exists within the bean factory. " + "Cannot post process session factory to add Hibernate resource definitions."); } }