List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:org.apache.falcon.extensions.Extension.java
@Override public List<Entity> getEntities(final String extensionName, final Properties extensionProperties) throws FalconException { if (StringUtils.isBlank(extensionName)) { throw new FalconException("Extension name cannot be null or empty"); }//from w w w . j ava 2 s . co m validateProperties(extensionProperties); String name = extensionName.toLowerCase(); AbstractExtension extension = ExtensionFactory.getExtensionType(name); if (extension != null) { extension.validate(extensionProperties); Properties props = extension.getAdditionalProperties(extensionProperties); if (props != null && !props.isEmpty()) { extensionProperties.putAll(props); } } ExtensionStore store = ExtensionService.getExtensionStore(); String resourceName = extensionProperties.getProperty(ExtensionProperties.RESOURCE_NAME.getName()); if (StringUtils.isBlank(resourceName)) { resourceName = name; } Map<String, String> extensionResources = store.getExtensionResources(name); /* Get the resources */ String extensionTemplate = getExtensionTemplate(store, extensionResources, resourceName); String wfPath = getWFPath(extensionResources, resourceName); /* Get Lib path */ String wfLibPath = store.getExtensionLibPath(name); Entity entity = ExtensionProcessBuilderUtils.createProcessFromTemplate(extensionTemplate, name, extensionProperties, wfPath, wfLibPath); if (entity == null) { throw new FalconException("Entity created from the extension template cannot be null"); } LOG.info("Extension processing complete"); return Arrays.asList(entity); }
From source file:org.apache.gobblin.util.test.RetentionTestHelper.java
/** * * Does gobblin retention for test data. {@link DatasetCleaner} which does retention in production can not be directly called as we need to resolve some * runtime properties like ${testNameTempPath}. This directory contains all the setup data created for a test by {@link RetentionTestDataGenerator#setup()}. * It is unique for each test./* w ww.j ava2s . c o m*/ * The default {@link ConfigClient} used by {@link DatasetCleaner} connects to config store configs. We need to provide a * mock {@link ConfigClient} since the configs are in classpath and not on config store. * * @param retentionConfigClasspathResource this is the same jobProps/config files used while running a real retention job * @param testNameTempPath temp path for this test where test data is generated */ public static void clean(FileSystem fs, Path retentionConfigClasspathResource, Optional<Path> additionalJobPropsClasspathResource, Path testNameTempPath) throws Exception { Properties additionalJobProps = new Properties(); if (additionalJobPropsClasspathResource.isPresent()) { try (final InputStream stream = RetentionTestHelper.class.getClassLoader() .getResourceAsStream(additionalJobPropsClasspathResource.get().toString())) { additionalJobProps.load(stream); } } if (retentionConfigClasspathResource.getName().endsWith(".job")) { Properties jobProps = new Properties(); try (final InputStream stream = RetentionTestHelper.class.getClassLoader() .getResourceAsStream(retentionConfigClasspathResource.toString())) { jobProps.load(stream); for (Entry<Object, Object> entry : jobProps.entrySet()) { jobProps.put(entry.getKey(), StringUtils.replace((String) entry.getValue(), "${testNameTempPath}", testNameTempPath.toString())); } } MultiCleanableDatasetFinder finder = new MultiCleanableDatasetFinder(fs, jobProps); for (Dataset dataset : finder.findDatasets()) { ((CleanableDataset) dataset).clean(); } } else { Config testConfig = ConfigFactory.parseResources(retentionConfigClasspathResource.toString()) .withFallback(ConfigFactory.parseMap(ImmutableMap.of("testNameTempPath", PathUtils.getPathWithoutSchemeAndAuthority(testNameTempPath).toString()))) .resolve(); ConfigClient client = mock(ConfigClient.class); when(client.getConfig(any(String.class))).thenReturn(testConfig); Properties jobProps = new Properties(); jobProps.setProperty(CleanableDatasetBase.SKIP_TRASH_KEY, Boolean.toString(true)); jobProps.setProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_URI, "dummy"); jobProps.setProperty(ConfigurationKeys.CONFIG_MANAGEMENT_STORE_ENABLED, "true"); jobProps.putAll(additionalJobProps); @SuppressWarnings("unchecked") DatasetsFinder<CleanableDataset> finder = (DatasetsFinder<CleanableDataset>) GobblinConstructorUtils .invokeFirstConstructor( Class.forName( testConfig.getString(MultiCleanableDatasetFinder.DATASET_FINDER_CLASS_KEY)), ImmutableList.of(fs, jobProps, testConfig, client), ImmutableList.of(fs, jobProps, client)); for (CleanableDataset dataset : finder.findDatasets()) { dataset.clean(); } } }
From source file:com.quartzdesk.executor.web.spring.SpringProfilesActivator.java
/** * Merges properties from the {@code default-quartzdesk-executor.properties} and * <code>${quartzdesk-executor.work.dir}/quartzdesk-executor.properties</code> (if it exists) and returns the value * of the {@code db.profile.name} configuration property. * * @param workDir the QuartzDesk Executor work directory. * @return the database profile to activate. *//*ww w. j a v a 2 s . co m*/ private String getDatabaseProfile(WorkDir workDir) { Properties mergedCfg = new Properties(); /* * 1. read default-quartzdesk-executor.properties */ InputStream defaultCfgIns = null; try { defaultCfgIns = CommonUtils.getResourceAsStream(DEFAULT_QUARTZDESK_EXECUTOR_CFG); if (defaultCfgIns == null) throw new ApplicationContextException("Default QuartzDesk Executor configuration: " + DEFAULT_QUARTZDESK_EXECUTOR_CFG + " not found."); Properties defaultCfg = new Properties(); defaultCfg.load(defaultCfgIns); mergedCfg.putAll(defaultCfg); } catch (IOException e) { throw new ApplicationContextException( "Error reading default QuartzDesk Executor configuration: " + DEFAULT_QUARTZDESK_EXECUTOR_CFG, e); } finally { IOUtils.close(defaultCfgIns); } /* * 2. read ${quartzdesk-executor.work.dir}/quartzdesk-executor.properties */ File cfgFile = new File(workDir.getRoot(), "quartzdesk-executor.properties"); if (IOUtils.isReadableFile(cfgFile)) { InputStream cfgIns = null; try { cfgIns = new FileInputStream(cfgFile); Properties cfg = new Properties(); cfg.load(cfgIns); mergedCfg.putAll(cfg); } catch (IOException e) { throw new ApplicationContextException( "Error reading QuartzDesk configuration: " + cfgFile.getAbsoluteFile(), e); } finally { IOUtils.close(cfgIns); } } String dbProfile = mergedCfg.getProperty(CONFIG_KEY_DB_PROFILE); if (dbProfile == null) { throw new ApplicationContextException( "QuartzDesk Executor configuration property: " + CONFIG_KEY_DB_PROFILE + " not defined."); } return dbProfile.trim(); }
From source file:com.dtolabs.rundeck.ExpandRunServer.java
/** * Create properties for template expansion * * @return/*from w w w . ja v a 2s . co m*/ */ private Properties createConfiguration(final Properties defaults) throws UnknownHostException { final Properties properties = new Properties(); properties.putAll(defaults); final String localhostname = getHostname(); if (null != localhostname) { properties.put("server.hostname", localhostname); } properties.put("rdeck.base", forwardSlashPath(basedir)); properties.put(SERVER_DATASTORE_PATH, forwardSlashPath(datadir.getAbsolutePath()) + "/grailsdb"); properties.put("rundeck.log.dir", forwardSlashPath(serverdir.getAbsolutePath()) + "/logs"); properties.put("rundeck.launcher.jar.location", forwardSlashPath(thisJar.getAbsolutePath())); properties.put(RUNDECK_SERVER_CONFIG_DIR, forwardSlashPath(this.configDir.getAbsolutePath())); for (final String configProperty : configProperties) { if (null != System.getProperty(configProperty)) { properties.put(configProperty, forwardSlashPath(System.getProperty(configProperty))); } } return properties; }
From source file:org.apache.wiki.providers.AbstractFileProvider.java
/** * Get custom properties using {@link this.addCustomPageProperties}, validate them using {@link this.validateCustomPageProperties} * and add them to default properties provided * /*from w w w. ja v a 2 s . c om*/ * @since 2.10.2 */ protected void getCustomProperties(WikiPage page, Properties defaultProperties) throws IOException { Properties customPageProperties = addCustomProperties(page, defaultProperties); validateCustomPageProperties(customPageProperties); defaultProperties.putAll(customPageProperties); }
From source file:org.apache.jmeter.report.dashboard.ReportGenerator.java
/** * Instantiates a new report generator./*from w w w . ja v a 2s .c o m*/ * * @param resultsFile * the test results file * @param resultCollector * Can be null, used if generation occurs at end of test * @throws ConfigurationException when loading configuration from file fails */ public ReportGenerator(String resultsFile, ResultCollector resultCollector) throws ConfigurationException { if (!CSV_OUTPUT_FORMAT) { throw new IllegalArgumentException( "Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property"); } LOG.info("ReportGenerator will use for Parsing the separator:'" + CSV_DEFAULT_SEPARATOR + "'"); File file = new File(resultsFile); if (resultCollector == null) { if (!(file.isFile() && file.canRead())) { throw new IllegalArgumentException(String.format("Cannot read test results file : %s", file)); } LOG.info("Will only generate report from results file:" + resultsFile); } else { if (file.exists() && file.length() > 0) { throw new IllegalArgumentException("Results file:" + resultsFile + " is not empty"); } LOG.info("Will generate report at end of test from results file:" + resultsFile); } this.resultCollector = resultCollector; this.testFile = file; final Properties merged = new Properties(); File rgp = new File(JMeterUtils.getJMeterBinDir(), REPORTGENERATOR_PROPERTIES); if (LOG.isInfoEnabled()) { LOG.info("Reading report generator properties from:" + rgp.getAbsolutePath()); } merged.putAll(loadProps(rgp)); if (LOG.isInfoEnabled()) { LOG.info("Merging with JMeter properties"); } merged.putAll(JMeterUtils.getJMeterProperties()); configuration = ReportGeneratorConfiguration.loadFromProperties(merged); }
From source file:com.iyonger.apm.web.configuration.Config.java
/** * Load database related properties. (database.conf) *//*from ww w .j a v a2s . c o m*/ protected void loadDatabaseProperties() { checkNotNull(home); Properties properties = home.getProperties("database.conf"); properties.put("NGRINDER_HOME", home.getDirectory().getAbsolutePath()); properties.putAll(System.getProperties()); }
From source file:org.cesecore.keys.token.BaseCryptoToken.java
@Override public void setProperties(Properties properties) { if (properties == null) { this.properties = new Properties(); } else {//from w w w . java2s. c o m if (log.isDebugEnabled()) { // This is only a sections for debug logging. If we have enabled debug logging we don't want to display any password in the log. // These properties may contain autoactivation PIN codes and we will, only when debug logging, replace this with "hidden". if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY) || properties.containsKey("PIN")) { Properties prop = new Properties(); prop.putAll(properties); if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)) { prop.setProperty(CryptoToken.AUTOACTIVATE_PIN_PROPERTY, "hidden"); } if (properties.containsKey("PIN")) { prop.setProperty("PIN", "hidden"); } log.debug("Prop: " + (prop != null ? prop.toString() : "null")); } else { // If no autoactivation PIN codes exists we can debug log everything as original. log.debug("Properties: " + (properties != null ? properties.toString() : "null")); } } // if (log.isDebugEnabled()) this.properties = properties; String authCode = BaseCryptoToken.getAutoActivatePin(properties); this.mAuthCode = authCode == null ? null : authCode.toCharArray(); } }
From source file:org.commonjava.aprox.core.expire.ScheduleManager.java
@Override public void init() throws AproxLifecycleException { try {// w ww .ja va2 s . co m final Properties props = new Properties(); final Map<String, String> configuration = schedulerConfig.getConfiguration(); if (configuration != null) { props.putAll(configuration); } final StringBuilder sb = new StringBuilder(); for (final String key : props.stringPropertyNames()) { if (sb.length() > 0) { sb.append('\n'); } sb.append(key).append(" = ").append(props.getProperty(key)); } logger.info("Scheduler properties:\n\n{}\n\n", sb); final StdSchedulerFactory fac = new StdSchedulerFactory(props); scheduler = fac.getScheduler(); if (eventDispatcher != null) { scheduler.getListenerManager() .addSchedulerListener(new AproxScheduleListener(scheduler, eventDispatcher)); scheduler.getListenerManager().addTriggerListener(new AproxTriggerListener(eventDispatcher)); } scheduler.start(); } catch (final SchedulerException e) { throw new AproxLifecycleException("Failed to start scheduler", e); } }
From source file:org.apache.maven.cli.NoSyspropChangingMavenCli.java
static void populateProperties(CommandLine commandLine, Properties systemProperties, Properties userProperties) { EnvironmentUtils.addEnvVars(systemProperties); // ---------------------------------------------------------------------- // Options that are set on the command line become system properties // and therefore are set in the session properties. System properties // are most dominant. // ---------------------------------------------------------------------- if (commandLine.hasOption(CLIManager.SET_SYSTEM_PROPERTY)) { String[] defStrs = commandLine.getOptionValues(CLIManager.SET_SYSTEM_PROPERTY); if (defStrs != null) { for (int i = 0; i < defStrs.length; ++i) { setCliProperty(defStrs[i], userProperties); }/*from w ww . j a v a2s . c o m*/ } } systemProperties.putAll(System.getProperties()); // ---------------------------------------------------------------------- // Properties containing info about the currently running version of Maven // These override any corresponding properties set on the command line // ---------------------------------------------------------------------- Properties buildProperties = CLIReportingUtils.getBuildProperties(); String mavenVersion = buildProperties.getProperty(CLIReportingUtils.BUILD_VERSION_PROPERTY); systemProperties.setProperty("maven.version", mavenVersion); String mavenBuildVersion = CLIReportingUtils.createMavenVersionString(buildProperties); systemProperties.setProperty("maven.build.version", mavenBuildVersion); }