List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:se.ivankrizsan.messagecowboy.integrationtest.taskexecutionstatuscleanup.TaskExecutionStatusCleanupTestConfiguration.java
/** * Overrides properties configured on beans. *//* w ww.j a va2 s .c o m*/ @Bean() @Lazy(false) @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public static BeanFactoryPostProcessor propertyOverrideConfigurer() { PropertyOverrideConfigurer theOverrideConfigurer = new PropertyOverrideConfigurer(); final Properties thePropertiesHolder = new Properties(); /* Task refresh interval. */ thePropertiesHolder.put("starterService.taskReschedulingCronExpression", "* 4/30 * * * ?"); /* Transport service configuration refresh interval. */ thePropertiesHolder.put("starterService.transportServiceConfigurationRefreshCronExpression", "* 5/30 * * * ?"); /* Task execution status reports cleanup interval. */ thePropertiesHolder.put("starterService.taskExecutionStatusCleanupCronExpression", "0/5 * * * * ?"); theOverrideConfigurer.setProperties(thePropertiesHolder); theOverrideConfigurer.setIgnoreInvalidKeys(false); theOverrideConfigurer.setIgnoreResourceNotFound(false); theOverrideConfigurer.setOrder(0); return theOverrideConfigurer; }
From source file:com.haulmont.cuba.web.jmx.JmxConnectionHelper.java
protected static <T> T withConnection(JmxInstance instance, JmxAction<T> action) { try {//from w w w . j a v a2s . co m if (Objects.equals(instance.getId(), LOCAL_JMX_INSTANCE_ID)) { return action.perform(instance, getLocalConnection()); } else { MBeanServerConnectionFactoryBean factoryBean = new MBeanServerConnectionFactoryBean(); String address = instance.getAddress(); if (!address.startsWith("service:")) { address = "service:jmx:rmi:///jndi/rmi://" + address + "/jmxrmi"; } factoryBean.setServiceUrl(address); String username = instance.getLogin(); if (StringUtils.isNotEmpty(username)) { Properties properties = new Properties(); properties.put("jmx.remote.credentials", new String[] { username, instance.getPassword() }); factoryBean.setEnvironment(properties); } factoryBean.afterPropertiesSet(); MBeanServerConnection connection = factoryBean.getObject(); T result; try { result = action.perform(instance, connection); } finally { try { factoryBean.destroy(); } catch (Exception ignored) { } } return result; } } catch (Exception e) { throw new JmxControlException(e); } }
From source file:uk.ac.cam.cl.dtg.picky.client.analytics.Analytics.java
private static void fillProperties(Properties properties, String filter) { properties.put(KEY_FILE_FILTER, Strings.nullToEmpty(filter)); }
From source file:Main.java
/** * Copy a set of properties from one Property to another. * //from w ww . j a v a 2 s. co m * * @param src_prop Source set of properties to copy from. * @param dest_prop Dest Properties to copy into. * **/ public static void copyProperties(Properties src_prop, Properties dest_prop) { for (Enumeration propertyNames = src_prop.propertyNames(); propertyNames.hasMoreElements();) { Object key = propertyNames.nextElement(); dest_prop.put(key, src_prop.get(key)); } }
From source file:Main.java
/** * Returns properties for complex XA datasource * * @param jndiName//from www . ja v a2s .c o m */ public static Properties xaDsProperties(String jndiName, boolean userName) { Properties params = commonDsProperties(jndiName, userName); //attributes //common params.put("xa-datasource-class", "org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource"); //xa-pool params.put("same-rm-override", "true"); params.put("interleaving", "true"); params.put("no-tx-separate-pool", "true"); params.put("pad-xid", "true"); params.put("wrap-xa-resource", "true"); //time-out params.put("xa-resource-timeout", "120"); //recovery params.put("no-recovery", "false"); params.put("recovery-plugin-class-name", "someClass5"); if (userName) { params.put("recovery-username", "sa"); params.put("recovery-password", "sa"); } else { params.put("recovery-security-domain", "HsqlDbRealm"); } return params; }
From source file:com.cloudera.recordservice.hcatalog.common.HCatRSUtil.java
public static Map<String, String> getInputJobProperties(HiveStorageHandler storageHandler, InputJobInfo inputJobInfo) {/*from ww w . j a v a2 s . co m*/ Properties props = inputJobInfo.getTableInfo().getStorerInfo().getProperties(); props.put(serdeConstants.SERIALIZATION_LIB, storageHandler.getSerDeClass().getName()); TableDesc tableDesc = new TableDesc(storageHandler.getInputFormatClass(), storageHandler.getOutputFormatClass(), props); if (tableDesc.getJobProperties() == null) { tableDesc.setJobProperties(new HashMap<String, String>()); } Properties mytableProperties = tableDesc.getProperties(); mytableProperties.setProperty(org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_NAME, inputJobInfo.getDatabaseName() + "." + inputJobInfo.getTableName()); Map<String, String> jobProperties = new HashMap<String, String>(); try { tableDesc.getJobProperties().put(HCatConstants.HCAT_KEY_JOB_INFO, HCatRSUtil.serialize(inputJobInfo)); storageHandler.configureInputJobProperties(tableDesc, jobProperties); } catch (IOException e) { throw new IllegalStateException("Failed to configure StorageHandler", e); } return jobProperties; }
From source file:net.itransformers.bgpPeeringMap.BgpPeeringMap.java
private static byte[] snmpWalk(Map<String, String> settings) throws Exception {//}, MibLoaderException { String queryParameters = settings.get("query.parameters"); String[] params = queryParameters.split(","); String mibDir = settings.get("mibDir"); MibLoaderHolder holder = new MibLoaderHolder(new File(System.getProperty("base.dir"), mibDir), false); SnmpManager snmpManager = new SnmpUdpV2Manager(holder.getLoader(), ipAddress.toString(), settings.get("community-ro"), 3, 1000, 10, 65535, 161); snmpManager.init();/* www . j a v a2 s . c om*/ //(holder,new UdpTransportMappingFactory(), new DefaultMessageDispatcherFactory()); String address = ipAddress; if (address == null) throw new RuntimeException("Resource Address is null"); Properties parameters = new Properties(); parameters.put(SnmpConfigurator.O_ADDRESS, Arrays.asList(address)); parameters.put(SnmpConfigurator.O_COMMUNITY, Arrays.asList(settings.get("community-ro"))); String version = settings.get("version") == null ? "2c" : settings.get("version"); int retriesInt = settings.get("retries") == null ? 3 : Integer.parseInt(settings.get("retries")); int timeoutInt = settings.get("timeout") == null ? 1200 : Integer.parseInt(settings.get("timeout")); int maxrepetitions = settings.get("max-repetitions") == null ? 100 : Integer.parseInt(settings.get("max-repetitions")); int nonrepeaters = settings.get("non-repeaters") == null ? 10 : Integer.parseInt(settings.get("max-repetitions")); parameters.put(SnmpConfigurator.O_VERSION, Arrays.asList(version)); parameters.put(SnmpConfigurator.O_TIMEOUT, Arrays.asList(timeoutInt)); parameters.put(SnmpConfigurator.O_RETRIES, Arrays.asList(retriesInt)); parameters.put(SnmpConfigurator.O_MAX_REPETITIONS, Arrays.asList(maxrepetitions)); parameters.put(SnmpConfigurator.O_NON_REPEATERS, Arrays.asList(nonrepeaters)); Node root = snmpManager.snmpWalk(params); SnmpXmlPrinter snmpXmlPrinter = new SnmpXmlPrinter(holder.getLoader(), root); String xml = snmpXmlPrinter.printTreeAsXML(); return xml.getBytes(); }
From source file:ca.ualberta.physics.cssdp.util.IntegrationTestScaffolding.java
@BeforeClass public static void setupDb() { ApplicationProperties.dropOverrides(); // initialize default properties Common.properties();/*from w ww .j a va2 s . com*/ // override the database connection url to point to an in-memory // database Properties overrides = new Properties(); overrides.put("common.logback.configuration", "src/test/resources/logback-test.xml"); overrides.setProperty("common.hibernate.connection.url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;TRACE_LEVEL_FILE=0;DB_CLOSE_ON_EXIT=FALSE"); ApplicationProperties.overrideDefaults(overrides); String url = Common.properties().getString("hibernate.connection.url"); String driver = Common.properties().getString("hibernate.connection.driver_class"); String user = Common.properties().getString("hibernate.connection.username"); String password = Common.properties().getString("hibernate.connection.password"); String scriptsDir = "../database/migrations"; Migrator migrator = new Migrator(url, driver, user, password, scriptsDir); migrator.initDb(); migrator.migrateUpAll(); }
From source file:eu.scidipes.toolkits.palibrary.utils.XMLUtils.java
/** * Converts a {@Node} instance into a readable <code>String</code> with optional formatting and XML * declaration// w ww . j a v a2 s .com * * @param doc * @param indentAndFormat * @param omitXmlDeclaration * @return the node contents as a String */ public static String nodeToString(final Node doc, final boolean indentAndFormat, final boolean omitXmlDeclaration) { final Properties outputProperties = new Properties(); outputProperties.put(OutputKeys.INDENT, indentAndFormat ? "yes" : "no"); outputProperties.put(OutputKeys.OMIT_XML_DECLARATION, omitXmlDeclaration ? "yes" : "no"); outputProperties.put("{http://xml.apache.org/xslt}indent-amount", indentAndFormat ? "2" : "0"); return nodeToString(doc, outputProperties); }
From source file:uk.ac.cam.cl.dtg.picky.client.analytics.Analytics.java
public static void sendAnalytics(ClientModel clientModel, String occasion) { Properties properties = new Properties(); properties.put(KEY_ANALYTICS_OCCASION, occasion); fillProperties(properties, clientModel.getDatasetBinding().get()); fillProperties(properties, clientModel.getFilterBinding().get()); fillProperties(properties, clientModel.getFileSelectionBinding().get()); fillProperties(properties, clientModel.getPlanBinding().get()); fillProperties(properties, clientModel.getRepositoryBinding().get()); fillProperties(properties, clientModel.getEntrySelection()); String url = clientModel.getServerURL().get(); new Thread(() -> upload(properties, url)).start(); }