List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:azkaban.jobtype.connectors.gobblin.GobblinHadoopJob.java
/** * If input parameter has preset value, it will load set of properties into job property for the Gobblin job. * Also, if user wants to validates the job properties(enabled by default), it will validate it based on the preset where * preset is basically used as a proxy to the use case. *///from w w w. j av a 2 s . c o m private void loadPreset() { String presetName = jobProps.get(GobblinConstants.GOBBLIN_PRESET_KEY); if (presetName == null) { return; } GobblinPresets preset = GobblinPresets.fromName(presetName); Properties presetProperties = gobblinPresets.get(preset); if (presetProperties == null) { throw new IllegalArgumentException( "Preset " + presetName + " is not supported. Supported presets: " + gobblinPresets.keySet()); } getLog().info("Loading preset " + presetName + " : " + presetProperties); Map<String, String> skipped = Maps.newHashMap(); for (String key : presetProperties.stringPropertyNames()) { if (jobProps.containsKey(key)) { skipped.put(key, presetProperties.getProperty(key)); continue; } jobProps.put(key, presetProperties.getProperty(key)); } getLog().info("Loaded preset " + presetName); if (!skipped.isEmpty()) { getLog().info( "Skipped some properties from preset as already exists in job properties. Skipped: " + skipped); } if (jobProps.getBoolean(GobblinConstants.GOBBLIN_PROPERTIES_HELPER_ENABLED_KEY, true)) { getValidator(preset).validate(jobProps); } }
From source file:org.opencastproject.capture.impl.RecordingImpl.java
/** * {@inheritDoc}//from w ww . j a v a2 s .com * * @see org.opencastproject.capture.api.AgentRecording#setProperties(java.util.Properties) */ public void setProperties(Properties props) { // Preserve the bundle context between property lists BundleContext ctx = null; if (this.props != null) { ctx = this.props.getBundleContext(); } this.props = new XProperties(); this.props.setBundleContext(ctx); for (String key : props.stringPropertyNames()) { props.put(key, props.getProperty(key)); } }
From source file:de.unihannover.se.processSimulation.interactive.ServerMain.java
private ExperimentRunSettings loadSettings(int requestId) throws IOException { final File requestDir = this.getRequestDir(requestId); final File paramsFile = new File(requestDir, SETTINGS_PROPERTIES); try (FileInputStream in = new FileInputStream(paramsFile)) { final Properties properties = new Properties(); properties.load(in);// w ww . jav a 2 s .c om ExperimentRunSettings ret = ExperimentRunSettings.defaultSettings(); for (final String name : properties.stringPropertyNames()) { final ExperimentRunParameters type = ExperimentRunParameters.valueOf(name); ret = ret.copyWithChangedParam(type, Double.parseDouble(properties.getProperty(name))); } return ret; } }
From source file:org.commonjava.maven.ext.manip.ManipulatingEventSpy.java
@Override public void onEvent(final Object event) throws Exception { boolean required = false; try {// ww w .jav a 2s. co m if (event instanceof ExecutionEvent) { final ExecutionEvent ee = (ExecutionEvent) event; required = Boolean.parseBoolean( ee.getSession().getRequest().getUserProperties().getProperty(REQUIRE_EXTENSION, "false")); final ExecutionEvent.Type type = ee.getType(); if (type == Type.ProjectDiscoveryStarted) { if (ee.getSession() != null) { session.setMavenSession(ee.getSession()); if (ee.getSession().getRequest().getPom() != null) { Properties config = configIO .parse(ee.getSession().getRequest().getPom().getParentFile()); String value = session.getUserProperties().getProperty("allowConfigFilePrecedence"); if (isNotEmpty(value) && "true".equalsIgnoreCase(value)) { session.getUserProperties().putAll(config); } else { for (String key : config.stringPropertyNames()) { if (!session.getUserProperties().containsKey(key)) { session.getUserProperties().setProperty(key, config.getProperty(key)); } } } } manipulationManager.init(session); } else { logger.error("Null session ; unable to continue"); return; } if (!session.isEnabled()) { logger.info("Manipulation engine disabled via command-line option"); return; } else if (ee.getSession().getRequest().getPom() == null) { logger.info("Manipulation engine disabled. No project found."); return; } else if (new File(ee.getSession().getRequest().getPom().getParentFile(), ManipulationManager.MARKER_FILE).exists()) { logger.info("Skipping manipulation as previous execution found."); return; } manipulationManager.scanAndApply(session); } } } catch (final ManipulationException e) { logger.error("Extension failure", e); if (required) { throw e; } else { session.setError(e); } } // Catch any runtime exceptions and mark them to fail the build as well. catch (final RuntimeException e) { logger.error("Extension failure", e); if (required) { throw e; } else { session.setError(new ManipulationException("Caught runtime exception", e)); } } finally { super.onEvent(event); } }
From source file:org.solenopsis.checkstyle.checks.TranslationCheck.java
/** * Loads the keys from the specified translation file into a set. * @param file translation file./*from w w w . ja v a 2 s . c o m*/ * @return a Set object which holds the loaded keys. */ private Set<String> getTranslationKeys(File file) { Set<String> keys = Sets.newHashSet(); InputStream inStream = null; try { inStream = new FileInputStream(file); final Properties translations = new Properties(); translations.load(inStream); keys = translations.stringPropertyNames(); } catch (final IOException ex) { logIoException(ex, file); } finally { Closeables.closeQuietly(inStream); } return keys; }
From source file:com.properned.model.MultiLanguageProperties.java
private void addProperties(Properties properties, Locale locale, PropertiesFile file) { Platform.runLater(new Runnable() { @Override/* www. j av a2s . com*/ public void run() { logger.info("Add a propertie file for the locale '" + locale + "'"); mapPropertiesByLocale.put(locale, properties); mapPropertiesFileByLocale.put(locale, file); Set<String> stringPropertyNames = properties.stringPropertyNames(); // use of a set to prevent duplicated values into the list Set<String> setPropertyTotal = new HashSet<>(listMessageKey); setPropertyTotal.addAll(stringPropertyNames); listMessageKey.clear(); listMessageKey.addAll(setPropertyTotal); baseName.set(file.getBaseName()); parentDirectoryPath.set(file.getParent() + File.separator); isLoaded.set(true); logger.info(listMessageKey.size() + " keys are loaded for locale '" + locale + "'"); } }); }
From source file:org.apache.asterix.common.config.PropertiesAccessor.java
private void loadAsterixBuildProperties() throws AsterixException { Properties gitProperties = new Properties(); try {// www .j a v a 2s . co m InputStream propertyStream = getClass().getClassLoader().getResourceAsStream("git.properties"); if (propertyStream != null) { gitProperties.load(propertyStream); for (final String name : gitProperties.stringPropertyNames()) { asterixBuildProperties.put(name, gitProperties.getProperty(name)); } } else { LOGGER.info("Build properties not found on classpath. Version API will return empty object"); } } catch (IOException e) { throw new AsterixException(e); } }
From source file:org.wso2.carbon.apimgt.jms.listener.utils.JMSTransportHandler.java
/** * This method will used to subscribe JMS and update throttle data map. * Then this will listen to topic updates and check all update and update throttle data map accordingly. *///from ww w. ja v a 2 s . c o m public void subscribeForJmsEvents() { Properties properties; Hashtable<String, String> parameters = new Hashtable<String, String>(); try { if (jmsConnectionProperties.getJmsConnectionProperties().isEmpty()) { properties = new Properties(); ClassLoader classLoader = getClass().getClassLoader(); properties.load(classLoader.getResourceAsStream(ListenerConstants.MB_PROPERTIES)); } else { properties = jmsConnectionProperties.getJmsConnectionProperties(); } for (final String name : properties.stringPropertyNames()) { parameters.put(name, properties.getProperty(name)); } String destination = jmsConnectionProperties.getDestination(); jmsConnectionFactory = new JMSConnectionFactory(parameters, ListenerConstants.CONNECTION_FACTORY_NAME); Map<String, String> messageConfig = new HashMap<String, String>(); messageConfig.put(JMSConstants.PARAM_DESTINATION, destination); int minThreadPoolSize = jmsConnectionProperties.getJmsTaskManagerProperties().getMinThreadPoolSize(); int maxThreadPoolSize = jmsConnectionProperties.getJmsTaskManagerProperties().getMaxThreadPoolSize(); int keepAliveTimeInMillis = jmsConnectionProperties.getJmsTaskManagerProperties() .getKeepAliveTimeInMillis(); int jobQueueSize = jmsConnectionProperties.getJmsTaskManagerProperties().getJobQueueSize(); JMSTaskManager jmsTaskManager = JMSTaskManagerFactory .createTaskManagerForService(jmsConnectionFactory, ListenerConstants.CONNECTION_FACTORY_NAME, new NativeWorkerPool(minThreadPoolSize, maxThreadPoolSize, keepAliveTimeInMillis, jobQueueSize, "JMS Threads", "JMSThreads" + UUID.randomUUID().toString()), messageConfig); jmsTaskManager.setJmsMessageListener( new JMSMessageListener(ServiceReferenceHolder.getInstance().getThrottleDataHolder())); jmsListener = new JMSListener(ListenerConstants.CONNECTION_FACTORY_NAME + "#" + destination, jmsTaskManager); jmsListener.startListener(); log.info("Starting jms topic consumer thread..."); } catch (IOException e) { log.error("Cannot read properties file from resources. " + e.getMessage(), e); } }
From source file:org.apache.tika.parser.ocr.TesseractOCRConfig.java
/** * Populate otherTesseractConfig from the given properties. * This assumes that any key-value pair where the key contains * an underscore is an option to be passed opaquely to Tesseract. * * @param properties properties file to read from. *//*from ww w .j a v a 2 s . c om*/ private void loadOtherTesseractConfig(Properties properties) { for (String k : properties.stringPropertyNames()) { if (k.contains("_")) { addOtherTesseractConfig(k, properties.getProperty(k)); } } }
From source file:org.apache.ranger.audit.utils.InMemoryJAASConfiguration.java
private void initialize(Properties properties) { LOG.debug("==> InMemoryJAASConfiguration.initialize()"); int prefixLen = JAAS_CONFIG_PREFIX_PARAM.length(); Map<String, SortedSet<Integer>> jaasClients = new HashMap<>(); for (String key : properties.stringPropertyNames()) { if (key.startsWith(JAAS_CONFIG_PREFIX_PARAM)) { String jaasKey = key.substring(prefixLen); StringTokenizer tokenizer = new StringTokenizer(jaasKey, "."); int tokenCount = tokenizer.countTokens(); if (tokenCount > 0) { String clientId = tokenizer.nextToken(); SortedSet<Integer> indexList = jaasClients.get(clientId); if (indexList == null) { indexList = new TreeSet<Integer>(); jaasClients.put(clientId, indexList); }/* w w w . j ava 2 s.co m*/ String indexStr = tokenizer.nextToken(); int indexId = isNumeric(indexStr) ? Integer.parseInt(indexStr) : -1; Integer clientIdIndex = Integer.valueOf(indexId); if (!indexList.contains(clientIdIndex)) { indexList.add(clientIdIndex); } } } } for (String jaasClient : jaasClients.keySet()) { for (Integer index : jaasClients.get(jaasClient)) { String keyPrefix = JAAS_CONFIG_PREFIX_PARAM + jaasClient + "."; if (index > -1) { keyPrefix = keyPrefix + String.valueOf(index) + "."; } String keyParam = keyPrefix + JAAS_CONFIG_LOGIN_MODULE_NAME_PARAM; String loginModuleName = properties.getProperty(keyParam); if (loginModuleName == null) { LOG.error("Unable to add JAAS configuration for " + "client [" + jaasClient + "] as it is missing param [" + keyParam + "]." + " Skipping JAAS config for [" + jaasClient + "]"); continue; } else { loginModuleName = loginModuleName.trim(); } keyParam = keyPrefix + JAAS_CONFIG_LOGIN_MODULE_CONTROL_FLAG_PARAM; String controlFlag = properties.getProperty(keyParam); AppConfigurationEntry.LoginModuleControlFlag loginControlFlag = null; if (controlFlag != null) { controlFlag = controlFlag.trim().toLowerCase(); if (controlFlag.equals("optional")) { loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; } else if (controlFlag.equals("requisite")) { loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; } else if (controlFlag.equals("sufficient")) { loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; } else if (controlFlag.equals("required")) { loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; } else { String validValues = "optional|requisite|sufficient|required"; LOG.warn("Unknown JAAS configuration value for (" + keyParam + ") = [" + controlFlag + "], valid value are [" + validValues + "] using the default value, REQUIRED"); loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; } } else { LOG.warn("Unable to find JAAS configuration (" + keyParam + "); using the default value, REQUIRED"); loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; } Map<String, String> options = new HashMap<>(); String optionPrefix = keyPrefix + JAAS_CONFIG_LOGIN_OPTIONS_PREFIX + "."; int optionPrefixLen = optionPrefix.length(); for (String key : properties.stringPropertyNames()) { if (key.startsWith(optionPrefix)) { String optionKey = key.substring(optionPrefixLen); String optionVal = properties.getProperty(key); if (optionVal != null) { optionVal = optionVal.trim(); try { if (optionKey.equalsIgnoreCase(JAAS_PRINCIPAL_PROP)) { optionVal = SecurityUtil.getServerPrincipal(optionVal, (String) null); } } catch (IOException e) { LOG.warn("Failed to build serverPrincipal. Using provided value:[" + optionVal + "]"); } } options.put(optionKey, optionVal); } } AppConfigurationEntry entry = new AppConfigurationEntry(loginModuleName, loginControlFlag, options); if (LOG.isDebugEnabled()) { StringBuilder sb = new StringBuilder(); sb.append("Adding client: [").append(jaasClient).append("{").append(index).append("}]\n"); sb.append("\tloginModule: [").append(loginModuleName).append("]\n"); sb.append("\tcontrolFlag: [").append(loginControlFlag).append("]\n"); for (String key : options.keySet()) { String val = options.get(key); sb.append("\tOptions: [").append(key).append("] => [").append(val).append("]\n"); } LOG.debug(sb.toString()); } List<AppConfigurationEntry> retList = applicationConfigEntryMap.get(jaasClient); if (retList == null) { retList = new ArrayList<AppConfigurationEntry>(); applicationConfigEntryMap.put(jaasClient, retList); } retList.add(entry); } } LOG.debug("<== InMemoryJAASConfiguration.initialize()"); }