List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:org.trpr.dataaccess.hbase.persistence.HBaseHandler.java
public void setHbaseConfigProps(Properties props) { hbaseConfiguration = HBaseConfiguration.create(); for (Object key : props.keySet()) { hbaseConfiguration.set(key.toString(), props.getProperty(key.toString())); }/* www . j a v a 2s.c o m*/ }
From source file:net.jawr.web.resource.bundle.locale.message.GrailsMessageBundleScriptCreator.java
/** * Reads the property names of the resourcebundle for the current locale from the war file. * @return/*from w w w . j ava 2 s. com*/ */ @SuppressWarnings("unchecked") private Set<String> getPropertyNamesFromWar() { Set<String> filenames = this.servletContext.getResourcePaths(PROPERTIES_DIR); Set<String> allPropertyNames = new HashSet<String>(); for (Iterator<String> it = filenames.iterator(); it.hasNext();) { String name = it.next(); if (matchesConfigParam(name)) { try { Properties props = new Properties(); props.load(servletContext.getResourceAsStream(name)); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Found " + props.keySet().size() + " message keys at " + name + "."); } for (Object key : props.keySet()) { allPropertyNames.add((String) key); } } catch (IOException e) { throw new BundlingProcessException("Unexpected error retrieving i18n grails properties file", e); } } } return allPropertyNames; }
From source file:com.siberhus.easyexecutor.EasyExecutor.java
private void overridePropeties(Properties main, Properties overrider) { for (Object keyObj : overrider.keySet()) { String key = (String) keyObj; String value = overrider.getProperty(key); main.setProperty(key, value);//from ww w . j a v a 2s .co m } }
From source file:jfs.sync.encryption.AbstractEncryptedFileProducerFactory.java
public AbstractEncryptedFileProducerFactory() { compressionLevels = new HashMap<>(); Properties p = new Properties(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try {/* w w w . j a v a 2s.c o m*/ p.load(classLoader.getResourceAsStream("compression-levels.properties")); } catch (Exception e) { LOG.error("()", e); } // try/catch for (Object property : p.keySet()) { String extension = "" + property; if (!"null".equals(extension)) { String limitString = p.getProperty(extension); try { long limit = Long.parseLong(limitString); limit = limit * 1024l * 1024l; // MB compressionLevels.put(extension, limit); } catch (Exception e) { LOG.error("()", e); } // try/catch } // if } // for }
From source file:net.dontdrinkandroot.lastfm.api.ws.AbstractLastfmWebServices.java
/** * You can specify how long the data of each method should be cached. Usually this defaults to * the expiration header sent by last.fm. The properties must be organized as follows: The key * is the package and method separated by a dot, the value is the time to live in milliseconds. * E.g.:/*from w w w . j a va 2s . c om*/ * * <pre> * artist.getinfo = 2419200000 * </pre> * * A special entry is exception, this is used to cache exceptions. * * @param ttls * Properties containing method time to lives. */ public final void setTimeToLive(final Properties ttls) { for (final Object propKey : ttls.keySet()) { final String method = (String) propKey; final Long timeToLive = Long.parseLong(ttls.getProperty(method)); this.logger.info("Overwriting ttl for method {} with {}ms", new Object[] { method.toLowerCase(), timeToLive }); this.ttls.put(method.toLowerCase(), timeToLive); } }
From source file:edu.ku.brc.ui.FeedBackSender.java
/** * Creates an array of POST method parameters to send with the version checking / usage tracking connection. * //from w w w . jav a2s .c om * @param item the item to fill * @return an array of POST parameters */ protected NameValuePair[] createPostParameters(final FeedBackSenderItem item) { Vector<NameValuePair> postParams = new Vector<NameValuePair>(); try { postParams.add(new NameValuePair("bug", item.getBug())); //$NON-NLS-1$ postParams.add(new NameValuePair("class_name", item.getClassName())); //$NON-NLS-1$ postParams.add(new NameValuePair("comments", item.getComments())); //$NON-NLS-1$ postParams.add(new NameValuePair("stack_trace", item.getStackTrace())); //$NON-NLS-1$ postParams.add(new NameValuePair("task_name", item.getTaskName())); //$NON-NLS-1$ postParams.add(new NameValuePair("title", item.getTitle())); //$NON-NLS-1$ // get the install ID String installID = UsageTracker.getInstallId(); postParams.add(new NameValuePair("id", installID)); //$NON-NLS-1$ Runtime runtime = Runtime.getRuntime(); Long usedMemory = runtime.maxMemory() - (runtime.totalMemory() + runtime.freeMemory()); Long maxMemory = runtime.maxMemory(); // get the OS name and version postParams.add(new NameValuePair("os_name", System.getProperty("os.name"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("os_version", System.getProperty("os.version"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("java_version", System.getProperty("java.version"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("java_vendor", System.getProperty("java.vendor"))); //$NON-NLS-1$ //$NON-NLS-2$ postParams.add(new NameValuePair("max_memory", maxMemory.toString())); //$NON-NLS-1$ postParams.add(new NameValuePair("used_memory", usedMemory.toString())); //$NON-NLS-1$ Properties props = item.getProps(); if (props != null) { for (Object key : props.keySet()) { postParams.add(new NameValuePair(key.toString(), props.getProperty(key.toString()))); //$NON-NLS-1$ } } //if (!UIRegistry.isRelease()) // For Testing Only { postParams.add(new NameValuePair("user_name", System.getProperty("user.name"))); //$NON-NLS-1$ try { postParams.add(new NameValuePair("ip", InetAddress.getLocalHost().getHostAddress())); //$NON-NLS-1$ } catch (UnknownHostException e) { } } String resAppVersion = UIRegistry.getAppVersion(); if (StringUtils.isEmpty(resAppVersion)) { resAppVersion = "Unknown"; } postParams.add(new NameValuePair("app_version", resAppVersion)); //$NON-NLS-1$ Vector<NameValuePair> extraStats = collectionSecondaryInfo(item); if (extraStats != null) { postParams.addAll(extraStats); } // create an array from the params NameValuePair[] paramArray = new NameValuePair[postParams.size()]; for (int i = 0; i < paramArray.length; ++i) { paramArray[i] = postParams.get(i); } return paramArray; } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:org.apache.openaz.xacml.util.XACMLProperties.java
/** * Get the policy-related properties from the given set of properties. These may or may not include ".url" * entries for each policy. The caller determines whether it should include them or not and sets checkURLs * appropriately. If checkURLs is false and there are ".url" entries, they are put into the result set * anyway.// w w w .j a va2 s . c om * * @param current * @param checkURLs * @return * @throws Exception */ public static Properties getPolicyProperties(Properties current, boolean checkURLs) throws Exception { Properties props = new Properties(); String[] lists = new String[2]; lists[0] = current.getProperty(XACMLProperties.PROP_ROOTPOLICIES); lists[1] = current.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES); // require that PROP_ROOTPOLICIES exist, even when it is empty if (lists[0] != null) { props.setProperty(XACMLProperties.PROP_ROOTPOLICIES, lists[0]); } else { logger.error("Missing property: " + XACMLProperties.PROP_ROOTPOLICIES); throw new Exception("Missing property: " + XACMLProperties.PROP_ROOTPOLICIES); } // require that PROP_REFERENCEDPOLICIES exist, even when it is empty if (lists[1] != null) { props.setProperty(XACMLProperties.PROP_REFERENCEDPOLICIES, lists[1]); } else { logger.error("Missing property: " + XACMLProperties.PROP_REFERENCEDPOLICIES); throw new Exception("Missing property: " + XACMLProperties.PROP_REFERENCEDPOLICIES); } Set<Object> keys = current.keySet(); for (String list : lists) { if (list == null || list.length() == 0) { continue; } Iterable<String> policies = Splitter.on(',').trimResults().omitEmptyStrings().split(list); if (policies == null) { continue; } for (String policy : policies) { for (Object key : keys) { if (key.toString().startsWith(policy)) { props.setProperty(key.toString(), current.getProperty(key.toString())); } } if (checkURLs) { // every policy must have a ".url" property String urlString = (String) props.get(policy + ".url"); if (urlString == null) { logger.error("Policy '" + policy + "' has no .url property"); throw new Exception("Policy '" + policy + "' has no .url property"); } // the .url must be a valid URL try { // if this does not throw an exception the URL is ok new URL(urlString); } catch (MalformedURLException e) { logger.error("Policy '" + policy + "' has bad .url property"); throw new Exception("Policy '" + policy + "' has bad .url property"); } } } } return props; }
From source file:org.apache.zookeeper.server.quorum.auth.MiniKdc.java
/** * Creates a MiniKdc./*from w w w . j a v a 2s .co m*/ * * @param conf MiniKdc configuration. * @param workDir working directory, it should be the build directory. Under * this directory an ApacheDS working directory will be created, this * directory will be deleted when the MiniKdc stops. * @throws Exception thrown if the MiniKdc could not be created. */ public MiniKdc(Properties conf, File workDir) throws Exception { if (!conf.keySet().containsAll(PROPERTIES)) { Set<String> missingProperties = new HashSet<String>(PROPERTIES); missingProperties.removeAll(conf.keySet()); throw new IllegalArgumentException("Missing configuration properties: " + missingProperties); } this.workDir = new File(workDir, Long.toString(System.currentTimeMillis())); if (!this.workDir.exists() && !this.workDir.mkdirs()) { throw new RuntimeException("Cannot create directory " + this.workDir); } LOG.info("Configuration:"); LOG.info("---------------------------------------------------------------"); for (Map.Entry<?, ?> entry : conf.entrySet()) { LOG.info(" {}: {}", entry.getKey(), entry.getValue()); } LOG.info("---------------------------------------------------------------"); this.conf = conf; port = Integer.parseInt(conf.getProperty(KDC_PORT)); String orgName = conf.getProperty(ORG_NAME); String orgDomain = conf.getProperty(ORG_DOMAIN); realm = orgName.toUpperCase(Locale.ENGLISH) + "." + orgDomain.toUpperCase(Locale.ENGLISH); }
From source file:com.edgenius.wiki.plugin.PluginServiceImpl.java
public void afterPropertiesSet() throws Exception { //register plugin InputStream input = FileUtil.getFileInputStream(linkResource); BufferedReader is = new BufferedReader(new InputStreamReader(input)); String linkPluginClz;// ww w . j a v a2s .co m while ((linkPluginClz = is.readLine()) != null) { //get macro class if (StringUtils.isBlank(linkPluginClz) || linkPluginClz.trim().startsWith("#")) { //skip comment continue; } linkPluginContainer.put(getPluginUuid(linkPluginClz), linkPluginClz); } IOUtils.closeQuietly(is); IOUtils.closeQuietly(input); input = FileUtil.getFileInputStream(pluginResource); Properties prop = new Properties(); prop.load(input); for (Iterator<Object> iter = prop.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); pluginContainer.put(key, prop.getProperty(key)); } IOUtils.closeQuietly(input); }