List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:com.wavemaker.runtime.data.util.DataServiceUtils.java
private static Properties loadDBProperties(File file, String sep) { String filepath = file.getAbsolutePath(); Tuple.Two<String, String> t = getBaseName(filepath, sep); Properties rtn = new Properties(); File basefile = new File(t.v1 + "." + t.v2); if (basefile.exists()) { rtn = SystemUtils.loadPropertiesFromFile(basefile.getAbsolutePath()); }/*from w w w. ja va 2 s . c o m*/ rtn.putAll(SystemUtils.loadPropertiesFromFile(filepath)); return rtn; }
From source file:arena.mail.MailSender.java
protected static Session makeSession(String smtpServer, String smtpServerDelimiter, Properties extraMailProperties) { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", "smtp"); // Support alternate syntax for core properties: "server,user,pass,localhost" StringTokenizer st = new StringTokenizer(smtpServer, smtpServerDelimiter); String property = null;/*from w w w .j a v a 2 s. c om*/ for (int i = 0; st.hasMoreElements(); i++) { property = st.nextToken(); if (!property.trim().equals("")) { mailProps.put(PROPS_KEYS[i], property); } } if (extraMailProperties != null) { mailProps.putAll(extraMailProperties); } LogFactory.getLog(MailSender.class) .debug("mailProps['mail.smtp.host'] ->" + mailProps.getProperty("mail.smtp.host")); return Session.getInstance(mailProps, null); }
From source file:com.googlecode.flyway.commandline.Main.java
/** * Loads the configuration from the configuration file. If a configuration file is specified using the -configfile * argument it will be used, otherwise the default config file (conf/flyway.properties) will be loaded. * * @param properties The properties object to load to configuration into. * @param args The command-line arguments passed in. * @throws FlywayException when the configuration file could not be loaded. *///from w w w . j ava2 s . com /* private -> for testing */ static void loadConfigurationFile(Properties properties, String[] args) throws FlywayException { String configFile = determineConfigurationFile(args); if (configFile != null) { try { String encoding = determineConfigurationFileEncoding(args); Reader fileReader = new InputStreamReader(new FileInputStream(configFile), encoding); String propertiesData = FileCopyUtils.copyToString(fileReader); properties.putAll(PropertiesUtils.loadPropertiesFromString(propertiesData)); } catch (IOException e) { throw new FlywayException("Unable to load config file: " + configFile, e); } } }
From source file:org.apache.openjpa.lib.conf.Configurations.java
/** * Return a plugin string that combines the properties of the given plugin * strings, where properties of <code>override</code> will override the * same properties of <code>orig</code>. *///from w w w. j ava 2 s . c o m public static String combinePlugins(String orig, String override) { if (StringUtils.isEmpty(orig)) return override; if (StringUtils.isEmpty(override)) return orig; String origCls = getClassName(orig); String overrideCls = getClassName(override); String cls; if (StringUtils.isEmpty(origCls)) cls = overrideCls; else if (StringUtils.isEmpty(overrideCls)) cls = origCls; else if (!origCls.equals(overrideCls)) return override; // completely different plugin else cls = origCls; String origProps = getProperties(orig); String overrideProps = getProperties(override); if (StringUtils.isEmpty(origProps)) return getPlugin(cls, overrideProps); if (StringUtils.isEmpty(overrideProps)) return getPlugin(cls, origProps); Properties props = parseProperties(origProps); props.putAll(parseProperties(overrideProps)); return getPlugin(cls, serializeProperties(props)); }
From source file:edu.isi.wings.portal.classes.domains.Domain.java
public static Domain importLegacyDomain(String domName, Config config, String legacyDomDir) { // Get Legacy apis PropertiesHelper.resetProperties();/*from w w w . ja v a 2 s . c o m*/ PropertiesHelper.loadWingsProperties(legacyDomDir + fsep + "wings.properties"); Properties legacyprops = TemplateFactory.createLegacyConfiguration(); legacyprops.putAll(DataFactory.createLegacyConfiguration()); legacyprops.putAll(ComponentFactory.createLegacyConfiguration()); DataCreationAPI ldc = DataFactory.getCreationAPI(legacyprops); ComponentCreationAPI lacc = ComponentFactory.getCreationAPI(legacyprops, false); ComponentCreationAPI lccc = ComponentFactory.getCreationAPI(legacyprops, true); TemplateCreationAPI ltc = TemplateFactory.getCreationAPI(legacyprops); // Get new apis Domain domain = Domain.createDefaultDomain(domName, config.getUserDir(), config.getExportUserUrl()); Properties props = config.getProperties(domain); DataCreationAPI dc = DataFactory.getCreationAPI(props); ComponentCreationAPI acc = ComponentFactory.getCreationAPI(props, false); ComponentCreationAPI ccc = ComponentFactory.getCreationAPI(props, true); TemplateCreationAPI tc = TemplateFactory.getCreationAPI(props); // Copy from legacy apis to new apis dc.copyFrom(ldc); acc.copyFrom(lacc); ccc.copyFrom(lccc); tc.copyFrom(ltc); // Copy legacy data/code directories to new data/code storage directory File srcDataDir = new File(PropertiesHelper.getDataDirectory()); File destDataDir = new File( domain.getDomainDirectory() + fsep + domain.getDataLibrary().getStorageDirectory()); File srcCodeDir = new File(PropertiesHelper.getCodeDirectory()); File destCodeDir = new File( domain.getDomainDirectory() + fsep + domain.getConcreteComponentLibrary().getStorageDirectory()); File srcBeamerDir = new File(PropertiesHelper.getOntologyDir() + fsep + "beamer"); File destBeamerDir = new File(domain.getDomainDirectory() + fsep + "beamer"); try { if (srcDataDir.isDirectory()) FileUtils.copyDirectory(srcDataDir, destDataDir); if (srcCodeDir.isDirectory()) { FileUtils.copyDirectory(srcCodeDir, destCodeDir); // FIXME: Setting executable permissions on all files for now for (File f : FileUtils.listFiles(destCodeDir, null, true)) { f.setExecutable(true); } } if (srcBeamerDir.isDirectory()) FileUtils.copyDirectory(srcBeamerDir, destBeamerDir); } catch (IOException e) { e.printStackTrace(); } return domain; }
From source file:com.netflix.config.ConfigurationManager.java
/** * Load resource configName.properties first. Then load configName-deploymentEnvironment.properties * into the system wide configuration. For example, if configName is "application", and deployment environment * is "test", this API will first load "application.properties", then load "application-test.properties" to * override any property that also exist in "application.properties". * //from ww w. j ava 2 s . c o m * @param configName prefix of the properties file name. * @throws IOException * @see DeploymentContext#getDeploymentEnvironment() */ public static void loadCascadedPropertiesFromResources(String configName) throws IOException { String defaultConfigFileName = configName + ".properties"; if (instance == null) { instance = getConfigInstance(); } ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL url = loader.getResource(defaultConfigFileName); if (url == null) { throw new IOException("Cannot locate " + defaultConfigFileName + " as a classpath resource."); } Properties props = getPropertiesFromFile(url); String environment = getDeploymentContext().getDeploymentEnvironment(); if (environment != null && environment.length() > 0) { String envConfigFileName = configName + "-" + environment + ".properties"; url = loader.getResource(envConfigFileName); if (url != null) { Properties envProps = getPropertiesFromFile(url); if (envProps != null) { props.putAll(envProps); } } } if (instance instanceof AggregatedConfiguration) { ConcurrentMapConfiguration config = new ConcurrentMapConfiguration(); config.loadProperties(props); ((AggregatedConfiguration) instance).addConfiguration(config, configName); } else { ConfigurationUtils.loadProperties(props, instance); } }
From source file:com.vmware.bdd.cli.commands.CommandsUtils.java
public static void writeProperties(Properties properties, String propertiesFilePath) { FileOutputStream fos = null;/*from w ww . j a va 2 s. c o m*/ try { Properties prop = null; File file = new File(propertiesFilePath); if (file.exists()) { prop = new Properties(); prop.load(new FileInputStream(propertiesFilePath)); prop.putAll(properties); } else { prop = properties; } fos = new FileOutputStream(propertiesFilePath); prop.store(fos, ""); } catch (IOException e) { System.out.println(e.getMessage()); } finally { if (fos != null) { try { fos.close(); } catch (IOException e1) { System.out.println(e1.getMessage()); } } } }
From source file:com.glaf.core.config.DBConfiguration.java
public static Properties toProperties(ConnectionDefinition conn) { if (conn != null) { Properties props = new Properties(); if (conn.getProperties() != null) { props.putAll(conn.getProperties()); }/*ww w. j av a 2s . c om*/ if (conn.getSubject() != null) { props.setProperty(SUBJECT, conn.getSubject()); } if (conn.getDatasource() != null) { props.setProperty(JDBC_DATASOURCE, conn.getDatasource()); } if (conn.getName() != null) { props.setProperty(JDBC_NAME, conn.getName()); } props.setProperty(JDBC_DRIVER, conn.getDriver()); props.setProperty(JDBC_URL, conn.getUrl()); props.setProperty(JDBC_USER, conn.getUser()); if (conn.getPassword() != null) { props.setProperty(JDBC_PASSWORD, conn.getPassword()); } if (conn.getProvider() != null) { props.setProperty(JDBC_PROVIDER, conn.getProvider()); } String type = getDatabaseType(conn.getUrl()); props.setProperty(JDBC_TYPE, type); if (conn.getHost() != null) { props.setProperty(HOST, conn.getHost()); } props.setProperty(PORT, String.valueOf(conn.getPort())); if (conn.getDatabase() != null) { props.setProperty(DATABASE, conn.getDatabase()); } return props; } return null; }
From source file:com.runwaysdk.business.generation.maven.MavenClasspathBuilder.java
public static MavenProject loadProject(File pomFile) throws IOException, XmlPullParserException { MavenProject ret = null;/*from w w w . j a va 2 s. com*/ MavenXpp3Reader mavenReader = new MavenXpp3Reader(); if (pomFile != null && pomFile.exists()) { FileReader reader = null; try { reader = new FileReader(pomFile); Model model = mavenReader.read(reader); model.setPomFile(pomFile); List<Repository> repositories = model.getRepositories(); Properties properties = model.getProperties(); properties.setProperty("basedir", pomFile.getParent()); Parent parent = model.getParent(); if (parent != null) { File parentPom = new File(pomFile.getParent(), parent.getRelativePath()); MavenProject parentProj = loadProject(parentPom); if (parentProj == null) { throw new CoreException("Unable to load parent project at " + parentPom.getAbsolutePath()); } repositories.addAll(parentProj.getRepositories()); model.setRepositories(repositories); properties.putAll(parentProj.getProperties()); } ret = new MavenProject(model); } finally { reader.close(); } } return ret; }
From source file:org.apache.samza.system.kafka.KafkaSystemAdmin.java
/** * Fetch stream properties for all intermediate streams. * * @param config kafka system config/*from ww w . ja v a 2 s . c o m*/ * @return a {@link Map} from {@code streamId} to stream {@link Properties} */ @VisibleForTesting static Map<String, Properties> getIntermediateStreamProperties(Config config) { Map<String, Properties> intermedidateStreamProperties = Collections.emptyMap(); ApplicationConfig appConfig = new ApplicationConfig(config); if (appConfig.getAppMode() == ApplicationConfig.ApplicationMode.BATCH) { StreamConfig streamConfig = new StreamConfig(config); intermedidateStreamProperties = JavaConverters.asJavaCollectionConverter(streamConfig.getStreamIds()) .asJavaCollection().stream().filter(streamConfig::getIsIntermediateStream) .collect(Collectors.toMap(Function.identity(), streamId -> { Properties properties = new Properties(); properties.putAll(streamConfig.getStreamProperties(streamId)); properties.putIfAbsent(TopicConfig.RETENTION_MS_CONFIG, String.valueOf(KafkaConfig.DEFAULT_RETENTION_MS_FOR_BATCH())); return properties; })); } return intermedidateStreamProperties; }