List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:com.glaf.template.renderer.RendererContainer.java
public static void render(Template template, Map<String, Object> model, Writer writer) { if (StringUtils.isEmpty(template.getLanguage())) { template.setLanguage("freemarker"); }/*from w w w. jav a 2 s . c om*/ model.put("template", template); Renderer renderer = getRenderer(template); if (renderer != null) { Properties properties = MessageProperties.getProperties(); if (properties != null) { Iterator<?> iterator = properties.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = properties.getProperty(key); if (!model.containsKey(key) && value != null) { model.put(key, value); } } } renderer.render(model, writer); } }
From source file:com.github.dbourdette.glass.job.util.JobDataMapUtils.java
public static JobDataMap fromProperties(String dataMap) { if (StringUtils.isEmpty(dataMap)) { return new JobDataMap(); }/*from w w w . j ava 2 s.co m*/ Properties props = new Properties(); try { props.load(new StringReader(dataMap)); } catch (IOException e) { throw new RuntimeException(e); } JobDataMap map = new JobDataMap(); for (Object key : props.keySet()) { map.put(key, props.getProperty((String) key)); } return map; }
From source file:eu.eidas.node.utils.PropertiesUtil.java
private static void initProps(Properties props) { LOG.info(LoggingMarkerMDC.SYSTEM_EVENT, "Loading properties"); propertiesMap = new HashMap<String, String>(); for (Object key : props.keySet()) { String keyStr = key.toString(); propertiesMap.put(keyStr, props.getProperty(keyStr)); }// w w w. j a v a2s . c om if (eidasXmlLocation != null && !props.containsKey(MASTER_CONF_FILE_PARAM)) { String fileRepositoryDir = eidasXmlLocation.substring(0, eidasXmlLocation.length() - MASTER_CONF_FILE.length()); propertiesMap.put(MASTER_CONF_FILE_PARAM, fileRepositoryDir); props.put(MASTER_CONF_FILE_PARAM, fileRepositoryDir); } }
From source file:com.flozano.socialauth.AuthProviderFactory.java
/** * /*from w w w .jav a 2s. c om*/ * @param id * the id of requested provider. It can be facebook, foursquare, * google, hotmail, linkedin,myspace, twitter, yahoo. * @param properties * properties containing key/secret for different providers and * information of custom provider. * @return AuthProvider the instance of requested provider based on given * id. If id is a URL it returns the OpenId provider. * @throws Exception */ public static AuthProvider getInstance(final String id, final Properties properties) throws Exception { for (Object key : properties.keySet()) { String str = key.toString(); if (str.startsWith("socialauth.")) { String val = str.substring("socialauth.".length()); registerProvider(val, Class.forName(properties.get(str).toString())); } } return loadProvider(id, properties); }
From source file:de.hypoport.ep2.support.configuration.properties.PropertiesLoader.java
private static synchronized void initializeInternal() { if (!initialized) { String propertyLocations = System.getProperty(PROPERTY_LOCATIONS); Properties loadedProperties = loadPropertiesLocations(propertyLocations); Set<Object> loadedPropertyKeys = new HashSet<Object>(loadedProperties.keySet()); mergePropertiesIntoSystemPropertiesWithoutOverwriting(loadedProperties); replacePropertyPlaceHolder(System.getProperties()); logProperties(loadedPropertyKeys, System.getProperties()); logProperties(sslPropertiesKeys, System.getProperties()); initialized = true;/*from w w w .j av a 2s. c o m*/ } }
From source file:lichen.orm.LichenOrmModule.java
public static DataSource buildDataSource(@Symbol(LichenOrmSymbols.DATABASE_CFG_FILE) String dbCfgFile, RegistryShutdownHub shutdownHub) throws IOException, ProxoolException { ResourceLoader resourceLoader = new DefaultResourceLoader(); Resource resource = resourceLoader.getResource(dbCfgFile); Properties info = new Properties(); info.load(resource.getInputStream()); PropertyConfigurator.configure(info); String poolNameKey = F.flow(info.keySet()).filter(new Predicate<Object>() { public boolean accept(Object element) { return element.toString().contains("alias"); }//from w w w . ja v a2 s . c o m }).first().toString(); if (poolNameKey == null) { throw new RuntimeException("?poolName"); } final String poolName = info.getProperty(poolNameKey); //new datasource ProxoolDataSource ds = new ProxoolDataSource(poolName); //register to shutdown shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener() { public void registryDidShutdown() { Flow<?> flow = F.flow(ProxoolFacade.getAliases()).filter(new Predicate<String>() { public boolean accept(String element) { return element.equals(poolName); } }); if (flow.count() == 1) { try { ProxoolFacade.removeConnectionPool(poolName); } catch (ProxoolException e) { //do nothing } } } }); return ds; }
From source file:com.glaf.template.renderer.RendererContainer.java
public static void evaluate(Template template, Map<String, Object> context, Writer writer) { if (template != null && StringUtils.isNotEmpty(template.getContent())) { String language = template.getLanguage(); if (language == null) { language = "freemarker"; }/* ww w . j a va 2 s. c o m*/ context.put("template", template); Properties properties2 = MessageProperties.getProperties(); if (properties2 != null) { Iterator<?> iterator = properties2.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = properties2.getProperty(key); if (!context.containsKey(key)) { context.put(key, value); } } } TemplateEngine engine = null; try { engine = (TemplateEngine) TemplateEngineFactory.getBean(language); if (engine != null) { engine.evaluate(template, context, writer); } } catch (Exception ex) { logger.debug(ex); throw new RuntimeException(ex); } } }
From source file:net.itransformers.bgpPeeringMap.BgpPeeringMap.java
private static Map<String, String> loadProperties(File file) throws IOException { Properties props = new Properties(); props.load(new FileInputStream(file)); HashMap<String, String> settings = new HashMap<String, String>(); for (Object key : props.keySet()) { settings.put((String) key, (String) props.get(key)); }/*from w ww .ja v a2s .c o m*/ return settings; }
From source file:org.apache.ofbiz.base.start.StartupCommandUtil.java
private static final void validateAllCommandArguments(CommandLine commandLine) throws StartupException { // Make sure no extra options are passed if (!commandLine.getArgList().isEmpty()) { throw new StartupException("unrecognized options / properties: " + commandLine.getArgList()); }/*from w w w .j a v a2 s . c o m*/ // PORTOFFSET validation if (commandLine.hasOption(StartupOption.PORTOFFSET.getName())) { Properties optionProperties = commandLine.getOptionProperties(StartupOption.PORTOFFSET.getName()); try { int portOffset = Integer.parseInt(optionProperties.keySet().iterator().next().toString()); if (portOffset < 0) { throw new StartupException("you can only pass positive integers to the option --" + StartupOption.PORTOFFSET.getName()); } } catch (NumberFormatException e) { throw new StartupException( "you can only pass positive integers to the option --" + StartupOption.PORTOFFSET.getName(), e); } } }
From source file:fr.cls.atoll.motu.library.misc.utils.PropertiesUtilities.java
/** * Delete from <code>props</code> every property for which the key is not prefixed by one elements from * <code>prefixes</code>./*from w w w .ja va 2 s . c om*/ * * @param props Properties * @param prefixes prefixes array * @return <code>props</code> eventyally modified. */ public static Properties filterPropertiesByPrefixes(Properties props, String[] prefixes) { if (props == null) { return null; } for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); boolean pass = false; for (int i = 0; i < prefixes.length; i++) { String prefix = prefixes[i]; if (key.startsWith(prefix)) { pass = true; break; } } if (!pass) { iter.remove(); } } return props; }