List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:de.steilerdev.myVerein.server.model.Settings.java
public Map<String, Object> getSettingsMap() { Map<String, Object> settingsMap = new HashMap<>(); try {/*from w ww . j a v a2s .com*/ Properties settingsFromFile; if ((settingsFromFile = loadSettingsFromFile()) != null) { for (Object key : settingsFromFile.keySet()) { settingsMap.put((String) key, settingsFromFile.get(key)); } } else { logger.warn("Unable to load settings from file"); } } catch (IOException e) { logger.error("Unable to load settings from file"); settingsMap = new HashMap<>(); } settingsMap.put("clubName", clubName); settingsMap.put("customUserFields", customUserFields); return settingsMap; }
From source file:com.cisco.oss.foundation.logging.FoundationLogger.java
private static void setupJULSupport(URL resource) { boolean julSupportEnabled = Boolean.valueOf(log4jConfigProps .getProperty(FoundationLoggerConstants.Foundation_JUL_SUPPORT_ENABLED.toString(), "false")); if (julSupportEnabled) { String appenderRef = log4jConfigProps .getProperty(FoundationLoggerConstants.Foundation_JUL_APPENDER_REF.toString()); if (StringUtils.isBlank(appenderRef)) { Enumeration allAppenders = Logger.getRootLogger().getAllAppenders(); while (allAppenders.hasMoreElements()) { Appender appender = (Appender) allAppenders.nextElement(); if (appender instanceof FileAppender) { appenderRef = appender.getName(); getLogger(FoundationLogger.class) .info("*** Using '" + appenderRef + "' as the Java util logging appender ref ***"); System.err.println( "*** Using '" + appenderRef + "' as the Java util logging appender ref ***"); break; }//from ww w.j a va2s.c om } } if (StringUtils.isBlank(appenderRef)) { throw new IllegalArgumentException( "Java util support was enabled but couldn't find a matching appender under the '" + FoundationLoggerConstants.Foundation_JUL_APPENDER_REF.toString() + "' key."); } Handler handler = null; Appender appender = Logger.getRootLogger().getAppender(appenderRef); if (appender == null) { Enumeration allAppenders = Logger.getRootLogger().getAllAppenders(); while (allAppenders.hasMoreElements()) { Appender tempAppender = (Appender) allAppenders.nextElement(); if (tempAppender instanceof AsyncAppender) { AsyncAppender asyncAppender = (AsyncAppender) tempAppender; Enumeration asyncAppenderAllAppenders = asyncAppender.getAllAppenders(); while (asyncAppenderAllAppenders.hasMoreElements()) { Appender asyncTempAppender = (Appender) asyncAppenderAllAppenders.nextElement(); if (appenderRef.equals(asyncTempAppender.getName())) { appender = asyncTempAppender; break; } } if (appender != null) { break; } } } } if (appender instanceof FileAppender) { try { handler = new FileHandler(((FileAppender) appender).getFile()); } catch (IOException e) { throw new IllegalArgumentException( "IOException encountered when trying to setup jul logging: " + e, e); } } else if (appender instanceof ConsoleAppender) { handler = new ConsoleHandler(); } else { getLogger(FoundationLogger.class) .error("got a reference to an unsupported appender: " + appenderRef); } if (handler != null) { // System.setProperty("java.util.logging.config.file",resource.getPath()); java.util.logging.LogManager.getLogManager().reset(); try { java.util.logging.LogManager.getLogManager().readConfiguration(resource.openStream()); } catch (IOException e) { throw new IllegalArgumentException( "IOException encountered when trying to read log4j properties file: " + e, e); } handler.setLevel(java.util.logging.Level.FINEST); handler.setFormatter(new FoundationLogFormatter()); java.util.logging.Logger rootLogger = java.util.logging.Logger.getLogger(""); rootLogger.addHandler(handler); rootLogger.setLevel(java.util.logging.Level.SEVERE); Properties julLoggerSubset = getPropertiesSubset("jul.logger"); if (!julLoggerSubset.isEmpty()) { Set<Object> keySet = julLoggerSubset.keySet(); for (Object key : keySet) { java.util.logging.Logger logger = java.util.logging.Logger.getLogger((String) key); logger.setLevel(java.util.logging.Level.parse((String) julLoggerSubset.get(key))); } } } } }
From source file:org.apache.sqoop.repository.JdbcRepositoryProvider.java
@Override public void configurationChanged() { LOG.info("Begin JdbcRepository reconfiguring."); JdbcRepositoryContext oldRepoContext = repoContext; repoContext = new JdbcRepositoryContext(SqoopConfiguration.getInstance().getContext()); // reconfigure jdbc handler String newJdbcHandlerClassName = repoContext.getHandlerClassName(); if (newJdbcHandlerClassName == null || newJdbcHandlerClassName.trim().length() == 0) { throw new SqoopException(RepositoryError.JDBCREPO_0001, newJdbcHandlerClassName); }/*from w ww. j ava2s . c o m*/ String oldJdbcHandlerClassName = oldRepoContext.getHandlerClassName(); if (!newJdbcHandlerClassName.equals(oldJdbcHandlerClassName)) { LOG.warn("Repository JDBC handler cannot be replaced at the runtime. " + "You might need to restart the server."); } // reconfigure jdbc driver String newJdbcDriverClassName = repoContext.getDriverClass(); if (newJdbcDriverClassName == null || newJdbcDriverClassName.trim().length() == 0) { throw new SqoopException(RepositoryError.JDBCREPO_0003, newJdbcDriverClassName); } String oldJdbcDriverClassName = oldRepoContext.getDriverClass(); if (!newJdbcDriverClassName.equals(oldJdbcDriverClassName)) { LOG.warn("Repository JDBC driver cannot be replaced at the runtime. " + "You might need to restart the server."); } // reconfigure max connection connectionPool.setMaxActive(repoContext.getMaximumConnections()); // reconfigure the url of repository String connectUrl = repoContext.getConnectionUrl(); String oldurl = oldRepoContext.getConnectionUrl(); if (connectUrl != null && !connectUrl.equals(oldurl)) { LOG.warn( "Repository URL cannot be replaced at the runtime. " + "You might need to restart the server."); } // if connection properties or transaction isolation option changes boolean connFactoryChanged = false; // compare connection properties if (!connFactoryChanged) { Properties oldProp = oldRepoContext.getConnectionProperties(); Properties newProp = repoContext.getConnectionProperties(); if (newProp.size() != oldProp.size()) { connFactoryChanged = true; } else { for (Object key : newProp.keySet()) { if (!newProp.getProperty((String) key).equals(oldProp.getProperty((String) key))) { connFactoryChanged = true; break; } } } } // compare the transaction isolation option if (!connFactoryChanged) { String oldTxOption = oldRepoContext.getTransactionIsolation().toString(); String newTxOption = repoContext.getTransactionIsolation().toString(); if (!newTxOption.equals(oldTxOption)) { connFactoryChanged = true; } } if (connFactoryChanged) { // try to reconfigure connection factory try { LOG.info("Reconfiguring Connection Factory."); Properties jdbcProps = repoContext.getConnectionProperties(); ConnectionFactory connFactory = new DriverManagerConnectionFactory(connectUrl, jdbcProps); new PoolableConnectionFactory(connFactory, connectionPool, statementPool, handler.validationQuery(), false, false, repoContext.getTransactionIsolation().getCode()); } catch (IllegalStateException ex) { // failed to reconfigure connection factory LOG.warn("Repository connection cannot be reconfigured currently. " + "You might need to restart the server."); } } // ignore the create schema option, because the repo url is not allowed to change LOG.info("JdbcRepository reconfigured."); }
From source file:info.magnolia.cms.beans.config.PropertiesInitializer.java
private void resolveNestedProperties() { Properties sysProps = SystemProperty.getProperties(); for (Iterator<Object> it = sysProps.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); String oldValue = (String) sysProps.get(key); String value = parseStringValue(oldValue, new HashSet<String>()); SystemProperty.getProperties().put(key, value.trim()); }// w w w.j a v a 2 s. c o m }
From source file:com.twinsoft.convertigo.engine.EnginePropertiesManager.java
public static String getPropertiesAsString(String title, Properties propertiesToGet) { if (propertiesToGet == null) { if (properties == null) { throw new IllegalStateException("Not initialized EnginePropertiesManager"); }/*w w w. java2 s .c o m*/ propertiesToGet = properties; } List<String> vProperties = new ArrayList<String>(propertiesToGet.size()); for (Object propKey : propertiesToGet.keySet()) { String propValue = propertiesToGet.getProperty((String) propKey); vProperties.add(propKey + "=" + propValue); } Collections.sort(vProperties); String msg = title + "\n"; for (String line : vProperties) { msg += line + "\n"; } return msg; }
From source file:org.apache.jackrabbit.core.query.lucene.JahiaIndexingConfigurationImpl.java
private void registerCustomNamespaces(NamespaceRegistryImpl namespaceRegistry, Properties customNamespaces) { for (Object key : customNamespaces.keySet()) { String prefix = (String) key; try {//from ww w. ja v a2 s . c o m namespaceRegistry.getURI(prefix); } catch (NamespaceException e) { String uri = customNamespaces.getProperty(prefix); try { namespaceRegistry.registerNamespace(prefix, uri); logger.info("Registered custom namespace with prefix '{}' and URI '{}'", prefix, uri); } catch (RepositoryException e1) { logger.warn("Unable to register custom namespace with prefix '" + prefix + "' and URI '" + uri + "'"); } } } }
From source file:com.urbancode.x2o.xml.NamespaceConfiguration.java
public void loadNameSpaceFromClassPath(String nameSpace) { BidiMap biMap = new DualHashBidiMap(); String filePath = nameSpace.replaceAll("\\.", Matcher.quoteReplacement("/")); String resourceName = filePath + "/" + NAMESPACE_FILE; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties props = new Properties(); log.debug("Looking for resource: " + resourceName); try {/* w w w . j a va 2 s . c o m*/ props.load(classLoader.getResourceAsStream(resourceName)); } catch (IOException e) { log.error(e.getClass() + " caught in " + this.getClass()); // swallow } // build the biDirectionalMap for (Object prop : props.keySet()) { biMap.put(prop, props.getProperty((String) prop)); } log.debug("added following elements into map: " + biMap.keySet()); log.debug("Added following value: " + biMap.values()); nameSpaces.put(nameSpace, biMap); }
From source file:kenh.expl.Environment.java
/** * Load function packages through system properties *//*from w w w. j av a 2 s . c o m*/ private void loadFunctionPackages_SystemProperties() { Properties p = System.getProperties(); Set keys = p.keySet(); for (Object key_ : keys) { if (key_ instanceof String) { String key = (String) key_; if (StringUtils.startsWith(key, FUNCTION_PATH_PREFIX + ".")) { String name = StringUtils.substringAfter(key, FUNCTION_PATH_PREFIX + "."); String funcPackage = p.getProperty(key); setFunctionPackage(name, funcPackage); } } } }
From source file:info.magnolia.importexport.PropertiesImportExport.java
public void createContent(Content root, InputStream propertiesStream) throws IOException, RepositoryException { Properties properties = new OrderedProperties(); properties.load(propertiesStream);// ww w . j a va 2 s. c om properties = keysToInnerFormat(properties); for (Object o : properties.keySet()) { String key = (String) o; String valueStr = properties.getProperty(key); String propertyName = StringUtils.substringAfterLast(key, "."); String path = StringUtils.substringBeforeLast(key, "."); String type = null; if (propertyName.equals("@type")) { type = valueStr; } else if (properties.containsKey(path + ".@type")) { type = properties.getProperty(path + ".@type"); } type = StringUtils.defaultIfEmpty(type, ItemType.CONTENTNODE.getSystemName()); Content c = ContentUtil.createPath(root, path, new ItemType(type)); populateContent(c, propertyName, valueStr); } }
From source file:org.jbpm.formbuilder.server.task.GuvnorTaskDefinitionService.java
@Override public List<TaskRef> query(String pkgName, String filter) throws TaskServiceException { HttpClient client = helper.getHttpClient(); GetMethod method = null;/*from w w w . j av a 2 s .c o m*/ try { method = helper.createGetMethod(helper.getApiSearchUrl(pkgName)); helper.setAuth(client, method); client.executeMethod(method); Properties props = new Properties(); props.load(method.getResponseBodyAsStream()); List<TaskRef> tasks = new ArrayList<TaskRef>(); for (Object key : props.keySet()) { String assetId = key.toString(); if (assetId.endsWith(ResourceType.BPMN2.getDefaultExtension()) || assetId.endsWith(ResourceType.DRF.getDefaultExtension()) || assetId.endsWith("bpmn2")) { String content = getTaskDefinitionContent(pkgName, assetId); if (content != null && !"".equals(content)) { List<TaskRef> processTasks = getProcessTasks(content, assetId); if (processTasks != null) { for (TaskRef ref : processTasks) { if (filter == null || "".equals(filter)) { tasks.add(ref); } else if (ref.getProcessId().contains(assetId) || ref.getTaskName().contains(filter)) { tasks.add(ref); } } } } } } return tasks; } catch (IOException e) { throw new TaskServiceException("Couldn't read task definitions", e); } catch (Exception e) { throw new TaskServiceException("Unexpected error", e); } finally { if (method != null) { method.releaseConnection(); } } }