List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:io.fabric8.apmagent.ApmConfiguration.java
public void initalizeFromProperties(Properties properties) { for (Map.Entry entry : properties.entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { setProperty(entry.getKey().toString(), entry.getValue().toString()); }/*from w w w. j a v a 2 s . c o m*/ } }
From source file:net.paoding.analysis.knife.PaodingMaker.java
private static Paoding createPaodingWithKnives(Properties p) throws Exception { // PaodingHolderPaoding // ?Paoding?paodingHolder Paoding paoding = new Paoding(); // Knife// ww w. j ava2 s.co m final Map /* <String, Knife> */ knifeMap = new HashMap /* * <String, * Knife> */(); final List /* <Knife> */ knifeList = new LinkedList/* <Knife> */(); final List /* <Function> */ functions = new LinkedList/* <Function> */(); Iterator iter = p.entrySet().iterator(); while (iter.hasNext()) { Map.Entry e = (Map.Entry) iter.next(); final String key = (String) e.getKey(); final String value = (String) e.getValue(); int index = key.indexOf(Constants.KNIFE_CLASS); if (index == 0 && key.length() > Constants.KNIFE_CLASS.length()) { final int end = key.indexOf('.', Constants.KNIFE_CLASS.length()); if (end == -1) { Class clazz = Class.forName(value); Knife knife = (Knife) clazz.newInstance(); knifeList.add(knife); knifeMap.put(key, knife); log.info("add knike: " + value); } else { // hashkey???????knife? // ?functionsknife?? functions.add(new Function() { public void run() throws Exception { String knifeName = key.substring(0, end); Object obj = knifeMap.get(knifeName); if (!obj.getClass().getName().equals("org.springframework.beans.BeanWrapperImpl")) { Class beanWrapperImplClass = Class .forName("org.springframework.beans.BeanWrapperImpl"); Method setWrappedInstance = beanWrapperImplClass.getMethod("setWrappedInstance", new Class[] { Object.class }); Object beanWrapperImpl = beanWrapperImplClass.newInstance(); setWrappedInstance.invoke(beanWrapperImpl, new Object[] { obj }); knifeMap.put(knifeName, beanWrapperImpl); obj = beanWrapperImpl; } String propertyName = key.substring(end + 1); Method setPropertyValue = obj.getClass().getMethod("setPropertyValue", new Class[] { String.class, Object.class }); setPropertyValue.invoke(obj, new Object[] { propertyName, value }); } }); } } } // ??? for (Iterator iterator = functions.iterator(); iterator.hasNext();) { Function function = (Function) iterator.next(); function.run(); } // ? paoding.setKnives(knifeList); return paoding; }
From source file:org.springframework.social.vkontakte.api.impl.AbstractVKontakteOperations.java
protected URI makeOperationURL(String method, Properties params, ApiVersion apiVersion) { URIBuilder uri = URIBuilder.fromUri(VK_REST_URL + method); preProcessURI(uri);/* w ww . java 2 s . c om*/ // add api version // TODO: I think finally we should migrate to latest api uri.queryParam("v", apiVersion.toString()); for (Map.Entry<Object, Object> objectObjectEntry : params.entrySet()) { uri.queryParam(objectObjectEntry.getKey().toString(), objectObjectEntry.getValue().toString()); } return uri.build(); }
From source file:com.globalsight.ling.tm3.tools.TM3Command.java
protected SessionFactory getSessionFactory(CommandLine command) { String username = null, password = null, connStr = null; // Order of operations: // - start with defaults // - load the file specified with -properties (if set), or the // default properties file. // - Look for command line options to override. if (command.hasOption(PROPERTIES)) { loadPropertiesFromFile(properties, command.getOptionValue(PROPERTIES), true); } else {//from w w w . j a v a 2 s. co m loadDefaultProperties(properties); } // Override any file properties with things passed on the command line Properties overrideProps = command.getOptionProperties(PROPERTY); for (Map.Entry<Object, Object> e : overrideProps.entrySet()) { properties.setProperty((String) e.getKey(), (String) e.getValue()); } username = properties.getProperty(TM3_USER_PROPERTY); password = properties.getProperty(TM3_PASSWORD_PROPERTY); connStr = properties.getProperty(TM3_CONNECTION_PROPERTY); if (username == null || password == null || connStr == null) { usage("Must specify " + TM3_USER_PROPERTY + ", " + TM3_PASSWORD_PROPERTY + ", and " + TM3_CONNECTION_PROPERTY + " with -Dprop=val or via properties file"); } Properties hibernateProps = new Properties(properties); hibernateProps.put("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect"); hibernateProps.put("hibernate.connection.driver_class", "com.mysql.jdbc.Driver"); hibernateProps.put("hibernate.connection.url", connStr); hibernateProps.put("hibernate.connection.username", username); hibernateProps.put("hibernate.connection.password", password); hibernateProps.put("hibernate.cglib.use_reflection_optimizer", "false"); // this // is // default // in // hibernate // 3.2 hibernateProps.put("hibernate.show_sql", "false"); hibernateProps.put("hibernate.format_sql", "false"); hibernateProps.put("hibernate.connection.pool_size", "1"); hibernateProps.put("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider"); // A little sketchy. Due to some undocumented (?) Hibernate // behavior, it will pick up hibernate cfg properties from elsewhere // in the classpath, even though we've specified them by hand. // As a result, this may end up unintentionally running c3p0 // connection pooling, which will release connections on commit. // This causes problems for multi-transaction commands (like // GlobalSight's migrate-tm), because it will kill the connection // in mid-operation. As a result, we force the release mode to // keep the connection open until we're done. hibernateProps.put("hibernate.connection.release_mode", "on_close"); Configuration cfg = new Configuration().addProperties(hibernateProps); cfg = HibernateConfig.extendConfiguration(cfg); if (requiresDataFactory()) { cfg = getDataFactory().extendConfiguration(cfg); } return cfg.buildSessionFactory(); }
From source file:org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter.java
/** * A utility method to convert mapping properties to the Map form. * /* w w w .j a va2 s. co m*/ * @see #setMappingProperties(Properties) */ @SuppressWarnings("rawtypes") protected void readXPathMappingProperties(Properties xpathMappingProperties) { // Get the namespaces for (Map.Entry entry : xpathMappingProperties.entrySet()) { String propertyName = (String) entry.getKey(); if (propertyName.startsWith("namespace.prefix.")) { String prefix = propertyName.substring(17); String namespace = (String) entry.getValue(); namespacesByPrefix.put(prefix, namespace); } } // Create the mapping for (Map.Entry entry : xpathMappingProperties.entrySet()) { String documentProperty = (String) entry.getKey(); String xpathStr = (String) entry.getValue(); if (documentProperty.startsWith(NAMESPACE_PROPERTY_PREFIX)) { // Ignore these now continue; } // Construct the XPath XPath xpath = xpathFactory.newXPath(); xpath.setNamespaceContext(this); XPathExpression xpathExpression = null; try { xpathExpression = xpath.compile(xpathStr); } catch (XPathExpressionException e) { throw new AlfrescoRuntimeException( "\n" + "Failed to create XPath expression: \n" + " Document property: " + documentProperty + "\n" + " XPath: " + xpathStr + "\n" + " Error: " + e.getMessage(), e); } // Persist it xpathExpressionMapping.put(documentProperty, xpathExpression); if (logger.isDebugEnabled()) { logger.debug("Added mapping from " + documentProperty + " to " + xpathStr); } } // Done }
From source file:com.microsoft.tfs.core.clients.build.internal.utils.XamlHelper.java
public static String save(final Properties properties) { ////w ww.j av a 2 s . c om // Only support parameters of type String for now // // The result should look something like this: // // <Dictionary x:TypeArguments="p:String, p:Object" // xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" // xmlns:p="http://schemas.microsoft.com/netfx/2008/xaml/schema" // xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> // <p:String x:Key="TestCategory" xml:space="preserve">Test // Category</p:String> // <p:String x:Key="SymbolStorePath" // xml:space="preserve">\\path\to\symbols</p:String> // </Dictionary> // Note that we're doing this using a string buffer to avoid JAXP // implementation issues when adding the clr-namespace declaration that // has issues between Sun's Java 1.4 and Java 6 final StringBuffer xaml = new StringBuffer(); xaml.append("<Dictionary x:TypeArguments=\"x:String, x:Object\" " //$NON-NLS-1$ + "xmlns=\"clr-namespace:System.Collections.Generic;assembly=mscorlib\" " //$NON-NLS-1$ + "xmlns:x=\"" //$NON-NLS-1$ + XAML_NAMESPACE + "\">"); //$NON-NLS-1$ xaml.append(NEWLINE); for (final Iterator it = properties.entrySet().iterator(); it.hasNext();) { final Entry entry = (Entry) it.next(); final String name = escapeValue((String) entry.getKey()); final String value = escapeValue((String) entry.getValue()); xaml.append(" <x:String x:Key=\""); //$NON-NLS-1$ xaml.append(name); xaml.append("\" xml:space=\"preserve\">"); //$NON-NLS-1$ xaml.append(value); xaml.append("</x:String>"); //$NON-NLS-1$ xaml.append(NEWLINE); } xaml.append("</Dictionary>"); //$NON-NLS-1$ return xaml.toString(); }
From source file:com.cloudera.sqoop.tool.JobTool.java
private int showJob(SqoopOptions opts) throws IOException { JobData data = this.storage.read(jobName); if (null == data) { LOG.error("No such job: " + jobName); return 1; }// w w w .j ava 2 s . c o m SqoopOptions childOpts = data.getSqoopOptions(); SqoopTool childTool = data.getSqoopTool(); System.out.println("Job: " + jobName); System.out.println("Tool: " + childTool.getToolName()); System.out.println("Options:"); System.out.println("----------------------------"); Properties props = childOpts.writeProperties(); for (Map.Entry<Object, Object> entry : props.entrySet()) { System.out.println(entry.getKey().toString() + " = " + entry.getValue()); } // TODO: This does not show entries in the Configuration // (SqoopOptions.getConf()) which were stored as different from the // default. return 0; }
From source file:org.apache.falcon.security.BasicAuthFilter.java
/** * Returns the configuration from Oozie configuration to be used by the authentication filter. * <p/>/* ww w. j a v a 2 s . co m*/ * All properties from Oozie configuration which name starts with {@link #FALCON_PREFIX} will * be returned. The keys of the returned properties are trimmed from the {@link #FALCON_PREFIX} * prefix, for example the Oozie configuration property name 'oozie.authentication.type' will * be just 'type'. * * @param configPrefix configuration prefix, this parameter is ignored by this implementation. * @param filterConfig filter configuration, this parameter is ignored by this implementation. * @return all Oozie configuration properties prefixed with {@link #FALCON_PREFIX}, without the * prefix. */ @Override protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) { Properties authProperties = new Properties(); Properties configProperties = StartupProperties.get(); // setting the cookie path to root '/' so it is used for all resources. authProperties.setProperty(AuthenticationFilter.COOKIE_PATH, "/"); for (Map.Entry entry : configProperties.entrySet()) { String name = (String) entry.getKey(); if (name.startsWith(FALCON_PREFIX)) { String value = (String) entry.getValue(); name = name.substring(FALCON_PREFIX.length()); authProperties.setProperty(name, value); } } if (UserGroupInformation.isSecurityEnabled()) { // replace _HOST in principal String principal = getKerberosPrincipalWithSubstitutedHost(configProperties); // principal cannot be null in secure mode, is validated in submission authProperties.setProperty(KerberosAuthenticationHandler.PRINCIPAL, principal); } return authProperties; }
From source file:org.apache.metron.common.stellar.shell.StellarExecutor.java
private Map<String, Object> getStellarConfig(Map<String, Object> globalConfig, Properties props) { Map<String, Object> ret = new HashMap<>(); ret.putAll(globalConfig);/*from www. ja v a 2 s . c o m*/ if (props != null) { for (Map.Entry<Object, Object> kv : props.entrySet()) { ret.put(kv.getKey().toString(), kv.getValue()); } } return ret; }
From source file:org.apache.oozie.service.XLogService.java
private void extractInfoForLogWebService(InputStream is) throws IOException { Properties props = new Properties(); props.load(is);/*from www. ja va 2 s .com*/ Configuration conf = new XConfiguration(); for (Map.Entry entry : props.entrySet()) { conf.set((String) entry.getKey(), (String) entry.getValue()); } XLogUtil logUtil = new XLogUtil(conf, "oozie"); logOverWS = logUtil.isLogOverEnable(); oozieLogRotation = logUtil.getLogRotation() == 0 ? oozieLogRotation : logUtil.getLogRotation(); oozieLogPath = logUtil.getLogPath() == null ? oozieLogPath : logUtil.getLogPath(); oozieLogName = logUtil.getLogFileName() == null ? oozieLogName : logUtil.getLogFileName(); logUtil = new XLogUtil(conf, "oozieError"); errorLogEnabled = logUtil.isLogOverEnable(); oozieErrorLogRotation = logUtil.getLogRotation() == 0 ? oozieErrorLogRotation : logUtil.getLogRotation(); oozieErrorLogPath = logUtil.getLogPath() == null ? oozieErrorLogPath : logUtil.getLogPath(); oozieErrorLogName = logUtil.getLogFileName() == null ? oozieErrorLogName : logUtil.getLogFileName(); logUtil = new XLogUtil(conf, "oozieaudit"); auditLogEnabled = logUtil.isLogOverEnable(); oozieAuditLogRotation = logUtil.getLogRotation() == 0 ? oozieAuditLogRotation : logUtil.getLogRotation(); oozieAuditLogPath = logUtil.getLogPath() == null ? oozieAuditLogPath : logUtil.getLogPath(); oozieAuditLogName = logUtil.getLogFileName() == null ? oozieAuditLogName : logUtil.getLogFileName(); }