java.util.Properties Java Examples
The following examples show how to use
java.util.Properties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SharedProxyConfig.java From consulo with Apache License 2.0 | 7 votes |
public static boolean store(@Nonnull ProxyParameters params) { if (params.host != null) { try { final Properties props = new Properties(); props.setProperty(HOST, params.host); props.setProperty(PORT, String.valueOf(params.port)); if (params.login != null) { props.setProperty(LOGIN, params.login); props.setProperty(PASSWORD, new String(params.password)); } ourEncryptionSupport.store(props, "Proxy Configuration", CONFIG_FILE); return true; } catch (Exception ignored) { } } else { FileUtil.delete(CONFIG_FILE); } return false; }
Example #2
Source File: GemFireTimeSync.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
@Override public boolean setProperties(Properties props) { String str; super.setProperties(props); str=props.getProperty("clock_sync_interval"); if (str != null) { clockSyncInterval = Integer.parseInt(str); props.remove("clock_sync_interval"); } str=props.getProperty("reply_wait_interval"); if (str != null) { replyWaitInterval = Integer.parseInt(str); props.remove("reply_wait_interval"); } if (props.size() > 0) { // this will not normally be seen by customers, even if there are unrecognized properties, because // jgroups error messages aren't displayed unless the debug flag is turned on log.error(ExternalStrings.DEBUG, "The following GemFireTimeSync properties were not recognized: " + props); return false; } return true; }
Example #3
Source File: EndpointListFromDirectoryProvider.java From CostFed with GNU Affero General Public License v3.0 | 6 votes |
synchronized void rebuildEndpoints() { endpoints.clear(); strEndpoints.clear(); File folder = new File(path); for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) continue; if (fileEntry.getName().endsWith(".temp")) continue; Properties prop = loadEndpoint(fileEntry); if (prop == null) continue; boolean enable = "true".equals(prop.getProperty("enable")); if (!enable) continue; boolean hasValidSummary = "ready".equals(prop.getProperty("summary")); if (!hasValidSummary) continue; String address = prop.getProperty("address"); if (address != null) { strEndpoints.add(address); } } log.info("endpoints have been rebuilt: " + strEndpoints); }
Example #4
Source File: BaseTestCase.java From arangodb-tinkerpop-provider with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { // host name and port see: arangodb.properties PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty("arangodb.hosts", "127.0.0.1:8529"); configuration.setProperty("arangodb.user", "gremlin"); configuration.setProperty("arangodb.password", "gremlin"); Properties arangoProperties = ConfigurationConverter.getProperties(configuration); client = new ArangoDBGraphClient(null, arangoProperties, "tinkerpop", 30000, true); client.deleteGraph(graphName); client.deleteCollection(vertices); client.deleteCollection(edges); }
Example #5
Source File: SortMergeJoinIT.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testJoinWithDifferentNumericJoinKeyTypes() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName1 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME); String tableName4 = getTableName(conn, JOIN_ORDER_TABLE_FULL_NAME); String query = "SELECT /*+ USE_SORT_MERGE_JOIN*/ \"order_id\", i.name, i.price, discount2, quantity FROM " + tableName4 + " o INNER JOIN " + tableName1 + " i ON o.\"item_id\" = i.\"item_id\" AND o.price = (i.price * (100 - discount2)) / 100.0 WHERE quantity < 5000"; try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); assertTrue (rs.next()); assertEquals(rs.getString(1), "000000000000004"); assertEquals(rs.getString(2), "T6"); assertEquals(rs.getInt(3), 600); assertEquals(rs.getInt(4), 15); assertEquals(rs.getInt(5), 4000); assertFalse(rs.next()); } finally { conn.close(); } }
Example #6
Source File: DistributedSQLTestBase.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void _startNetworkServer(String className, String name, int mcastPort, int netPort, String serverGroups, Properties extraProps, Boolean configureDefautHeap) throws Exception { final Class<?> c = Class.forName(className); // start a DataNode first. if (TestUtil.getFabricService().status() != FabricService.State.RUNNING) { _startNewServer(className, name, mcastPort, serverGroups, extraProps, configureDefautHeap); } DistributedSQLTestBase test = (DistributedSQLTestBase)c.getConstructor( String.class).newInstance(name); test.configureDefaultOffHeap = configureDefautHeap; final Properties props = new Properties(); test.setCommonProperties(props, mcastPort, serverGroups, extraProps); TestUtil.startNetServer(netPort, props); }
Example #7
Source File: MultiTest.java From mariadb-connector-j with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testInsertWithLeadingConstantValue() throws Exception { Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); props.setProperty("allowMultiQueries", "true"); try (Connection tmpConnection = openNewConnection(connUri, props)) { PreparedStatement insertStmt = tmpConnection.prepareStatement( "INSERT INTO MultiTesttest_table (col1, col2," + " col3, col4, col5) values('some value', ?, 'other value', ?, 'third value')"); insertStmt.setString(1, "a1"); insertStmt.setString(2, "a2"); insertStmt.addBatch(); insertStmt.setString(1, "b1"); insertStmt.setString(2, "b2"); insertStmt.addBatch(); insertStmt.executeBatch(); } }
Example #8
Source File: KafkaProducerManager.java From conductor with Apache License 2.0 | 6 votes |
@VisibleForTesting Properties getProducerProperties(KafkaPublishTask.Input input) { Properties configProperties = new Properties(); configProperties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, input.getBootStrapServers()); configProperties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, input.getKeySerializer()); String requestTimeoutMs = requestTimeoutConfig; if (Objects.nonNull(input.getRequestTimeoutMs())) { requestTimeoutMs = String.valueOf(input.getRequestTimeoutMs()); } String maxBlockMs = maxBlockMsConfig; if (Objects.nonNull(input.getMaxBlockMs())) { maxBlockMs = String.valueOf(input.getMaxBlockMs()); } configProperties.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, requestTimeoutMs); configProperties.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, maxBlockMs); configProperties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, STRING_SERIALIZER); return configProperties; }
Example #9
Source File: Chapter5.java From Natural-Language-Processing-with-Java-Second-Edition with MIT License | 6 votes |
private static void usingStanfordPOSTagger() { Properties props = new Properties(); props.put("annotators", "tokenize, ssplit, pos"); props.put("pos.model", "C:\\Current Books in Progress\\NLP and Java\\Models\\english-caseless-left3words-distsim.tagger"); props.put("pos.maxlen", 10); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); Annotation document = new Annotation(theSentence); pipeline.annotate(document); List<CoreMap> sentences = document.get(SentencesAnnotation.class); for (CoreMap sentence : sentences) { for (CoreLabel token : sentence.get(TokensAnnotation.class)) { String word = token.get(TextAnnotation.class); String pos = token.get(PartOfSpeechAnnotation.class); System.out.print(word + "/" + pos + " "); } System.out.println(); try { pipeline.xmlPrint(document, System.out); pipeline.prettyPrint(document, System.out); } catch (IOException ex) { ex.printStackTrace(); } } }
Example #10
Source File: PropertiesUtilTest.java From consultant with Apache License 2.0 | 6 votes |
@Test public void verifyMerge() { Properties source = new Properties(); Properties target = new Properties(); source.setProperty("key-1", "some-value"); source.setProperty("key-2", "other-value"); target.setProperty("key-1", "some-other-value"); target.setProperty("key-3", "new-value"); PropertiesUtil.sync(source, target); assertEquals("some-value", target.getProperty("key-1")); assertEquals("other-value", target.getProperty("key-2")); assertNull(target.getProperty("key-3")); }
Example #11
Source File: BaseDbFlatStorage.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Replace any properties for this resource with the resource's current set of properties. * * @param r * The resource for which properties are to be written. */ public void writeProperties(final String table, final String idField, final Object id, final String extraIdField, final String extraId, final Properties props, final boolean deleteFirst) { // if not properties table set, skip it if (table == null) return; if (props == null) return; // do this in a transaction m_sql.transact(new Runnable() { public void run() { writePropertiesTx(table, idField, id, extraIdField, extraId, props, deleteFirst); } }, "writeProperties:" + id); }
Example #12
Source File: TriplestoreStorageTest.java From IGUANA with GNU Affero General Public License v3.0 | 6 votes |
/** * @throws IOException */ @Test public void metaTest() throws IOException{ fastServerContainer = new ServerMock(); fastServer = new ContainerServer(fastServerContainer); fastConnection = new SocketConnection(fastServer); SocketAddress address1 = new InetSocketAddress(FAST_SERVER_PORT); fastConnection.connect(address1); String host = "http://localhost:8023"; TriplestoreStorage store = new TriplestoreStorage(host, host); Properties p = new Properties(); p.put(COMMON.EXPERIMENT_TASK_ID_KEY, "1/1/1"); p.setProperty(COMMON.EXPERIMENT_ID_KEY, "1/1"); p.setProperty(COMMON.CONNECTION_ID_KEY, "virtuoso"); p.setProperty(COMMON.SUITE_ID_KEY, "1"); p.setProperty(COMMON.DATASET_ID_KEY, "dbpedia"); p.put(COMMON.RECEIVE_DATA_START_KEY, "true"); p.put(COMMON.EXTRA_META_KEY, new Properties()); p.put(COMMON.NO_OF_QUERIES, 2); store.addMetaData(p); assertEquals(metaExp.trim(), fastServerContainer.getActualContent().trim()); }
Example #13
Source File: Runner.java From ethsigner with Apache License 2.0 | 6 votes |
private void writePortsToFile(final HttpServerService httpService) { final File portsFile = new File(dataPath.toFile(), "ethsigner.ports"); portsFile.deleteOnExit(); final Properties properties = new Properties(); properties.setProperty("http-jsonrpc", String.valueOf(httpService.actualPort())); LOG.info( "Writing ethsigner.ports file: {}, with contents: {}", portsFile.getAbsolutePath(), properties); try (final FileOutputStream fileOutputStream = new FileOutputStream(portsFile)) { properties.store( fileOutputStream, "This file contains the ports used by the running instance of Web3Provider. This file will be deleted after the node is shutdown."); } catch (final Exception e) { LOG.warn("Error writing ports file", e); } }
Example #14
Source File: CLISettings.java From sherlock with GNU General Public License v3.0 | 5 votes |
/** * Attempt to load configuration elements from a * file if the path to the config file has been * specified in the commandline settings. * * @throws IOException if an error reading/location the file occurs */ public void loadFromConfig() throws IOException { // If the config file is defined, attempt to load settings // from a properties file if (CONFIG_FILE == null) { log.info("No configuration file specified, using default/passed settings"); return; } log.info("Attempting to read config file at: {}", CONFIG_FILE); Field[] configFields = Utils.findFields(getClass(), Parameter.class); Properties props = new Properties(); InputStream is = new FileInputStream(CONFIG_FILE); props.load(is); for (Field configField : configFields) { String configName = configField.getName(); Class<?> type = configField.getType(); String configValue = props.getProperty(configName); if (configValue != null && configValue.length() > 0) { configField.setAccessible(true); try { if (type.getName().equals("int")) { configField.set(null, Integer.valueOf(configValue)); } else if (type.getName().equals("boolean")) { configField.set(null, Boolean.valueOf(configValue)); } else { configField.set(null, configValue); } } catch (IllegalAccessException | IllegalArgumentException e) { log.error("Could not set {} to {}: {}", configName, configValue, e.toString()); throw new IOException(String.format( "Failed to set %s to value %s", configName, configValue )); } } } }
Example #15
Source File: AbstractCipherStreamTest.java From commons-crypto with Apache License 2.0 | 5 votes |
protected CryptoOutputStream getCryptoOutputStream(final String transformation, final Properties props, final ByteArrayOutputStream baos, final byte[] key, final AlgorithmParameterSpec param, final boolean withChannel) throws IOException { if (withChannel) { return new CryptoOutputStream(transformation, props, Channels.newChannel(baos), new SecretKeySpec(key, "AES"), param); } return new CryptoOutputStream(transformation, props, baos, new SecretKeySpec(key, "AES"), param); }
Example #16
Source File: CodecEndpoint.java From quarkus with Apache License 2.0 | 5 votes |
public static KafkaConsumer<String, Pet> createPetConsumer() { Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:19092"); props.put(ConsumerConfig.GROUP_ID_CONFIG, "pet"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, PetCodec.class.getName()); props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true"); props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); KafkaConsumer<String, Pet> consumer = new KafkaConsumer<>(props); consumer.subscribe(Collections.singletonList("pets")); return consumer; }
Example #17
Source File: MessageLoader.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
private Properties loadProperties(String resource) throws IOException { Properties properties = new Properties(); // Load from property files try (InputStream in = getResourceAsStream("/" + resource + ".properties")) { if (in != null) { properties.load(in); } else { log.warn("Unable to load resource; resource " + resource + " is not found"); } } catch (IOException ioex) { log.error("Unable to load resource " + resource, ioex); throw ioex; } return properties; }
Example #18
Source File: TConnectionFactory.java From micro-integrator with Apache License 2.0 | 5 votes |
public static Connection createConnection(String type, Properties props) throws SQLException { type = type.toUpperCase(); if (Constants.EXCEL.equals(type)) { return new TExcelConnection(props); } else if (Constants.GSPREAD.equals(type)) { return new TGSpreadConnection(props); } else if (Constants.CUSTOM.equals(type)) { return new TCustomConnection(props); } else { throw new SQLException("Unsupported datasource type"); } }
Example #19
Source File: PropertyPlaceholder.java From PhrackCTF-Platform-Personal with Apache License 2.0 | 5 votes |
@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); propertyMap = new HashMap<String, String>(); for (Object key : props.keySet()) { String keyStr = key.toString(); String value = props.getProperty(keyStr); propertyMap.put(keyStr, value); } }
Example #20
Source File: AlfrescoPropertiesPersister.java From alfresco-core with GNU Lesser General Public License v3.0 | 5 votes |
private void strip(Properties props) { for (Enumeration<Object> keys = props.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); String val = StringUtils.trimTrailingWhitespace(props.getProperty(key)); if (logger.isTraceEnabled()) { logger.trace("Trimmed trailing whitespace for property " + key + " = " + val); } props.setProperty(key, val); } }
Example #21
Source File: StartManagementAgent.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void basicTests(VirtualMachine vm) throws Exception { // Try calling with null argument boolean exception = false; try { vm.startManagementAgent(null); } catch (NullPointerException e) { exception = true; } if (!exception) { throw new Exception("startManagementAgent(null) should throw NPE"); } // Try calling with a property value with a space in it Properties p = new Properties(); File f = new File("file with space"); try (FileWriter fw = new FileWriter(f)) { fw.write("com.sun.management.jmxremote.port=apa"); } p.put("com.sun.management.config.file", f.getAbsolutePath()); try { vm.startManagementAgent(p); } catch(AttachOperationFailedException ex) { // We expect parsing of "apa" above to fail, but if the file path // can't be read we get a different exception message if (!ex.getMessage().contains("NumberFormatException: For input string: \"apa\"")) { throw ex; } } }
Example #22
Source File: Carpates.java From component-runtime with Apache License 2.0 | 5 votes |
private static String loadComponentGav(final Path archive) { try (final JarFile file = new JarFile(archive.toFile()); final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/metadata.properties"))) { final Properties properties = new Properties(); properties.load(stream); return requireNonNull(properties.getProperty("component_coordinates"), "no component_coordinates in '" + archive + "'"); } catch (final IOException e) { throw new IllegalStateException(e); } }
Example #23
Source File: XMLConfigBuilder.java From QuickProject with Apache License 2.0 | 5 votes |
private TransactionFactory transactionManagerElement(XNode context) throws Exception { if (context != null) { String type = context.getStringAttribute("type"); Properties props = context.getChildrenAsProperties(); TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance(); factory.setProperties(props); return factory; } throw new BuilderException("Environment declaration requires a TransactionFactory."); }
Example #24
Source File: CuratorZookeeperCenterRepositoryTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test public void assertBuildCuratorClientWithOperationTimeoutMillisecondsEqualsZero() { final CuratorZookeeperCenterRepository customCenterRepository = new CuratorZookeeperCenterRepository(); Properties props = new Properties(); props.setProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey(), "0"); CenterConfiguration configuration = new CenterConfiguration(customCenterRepository.getType(), new Properties()); configuration.setServerLists(serverLists); customCenterRepository.setProps(props); customCenterRepository.init(configuration); assertThat(customCenterRepository.getProps().getProperty(ZookeeperPropertyKey.OPERATION_TIMEOUT_MILLISECONDS.getKey()), is("0")); customCenterRepository.persist("/test/children/build/3", "value1"); assertThat(customCenterRepository.get("/test/children/build/3"), is("value1")); }
Example #25
Source File: ProfileTest.java From keycloak with Apache License 2.0 | 5 votes |
@Test public void configWithPropertiesFile() throws IOException { Assert.assertEquals("community", Profile.getName()); Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.DOCKER)); Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION)); Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS)); File d = temporaryFolder.newFolder(); File f = new File(d, "profile.properties"); Properties p = new Properties(); p.setProperty("profile", "preview"); p.setProperty("feature.docker", "enabled"); p.setProperty("feature.impersonation", "disabled"); p.setProperty("feature.upload_scripts", "enabled"); PrintWriter pw = new PrintWriter(f); p.list(pw); pw.close(); System.setProperty("jboss.server.config.dir", d.getAbsolutePath()); Profile.init(); Assert.assertEquals("preview", Profile.getName()); Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.DOCKER)); Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.OPENSHIFT_INTEGRATION)); Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION)); Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS)); System.getProperties().remove("jboss.server.config.dir"); Profile.init(); }
Example #26
Source File: TimeUtil.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Loads a properties file that contains all kinds of time zone mappings. * * @param exceptionInterceptor * exception interceptor */ private static void loadTimeZoneMappings(ExceptionInterceptor exceptionInterceptor) { timeZoneMappings = new Properties(); try { timeZoneMappings.load(TimeUtil.class.getResourceAsStream(TIME_ZONE_MAPPINGS_RESOURCE)); } catch (IOException e) { throw ExceptionFactory.createException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), exceptionInterceptor); } // bridge all Time Zone ids known by Java for (String tz : TimeZone.getAvailableIDs()) { if (!timeZoneMappings.containsKey(tz)) { timeZoneMappings.put(tz, tz); } } }
Example #27
Source File: FlinkKafkaProducer.java From flink with Apache License 2.0 | 5 votes |
private static Properties getPropertiesFromBrokerList(String brokerList) { String[] elements = brokerList.split(","); // validate the broker addresses for (String broker: elements) { NetUtils.getCorrectHostnamePort(broker); } Properties props = new Properties(); props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList); return props; }
Example #28
Source File: PropertiesUtil.java From javers with Apache License 2.0 | 5 votes |
/** * @throws JaversException UNDEFINED_PROPERTY * @throws JaversException MALFORMED_PROPERTY */ public static <T extends Enum<T>> T getEnumProperty(Properties properties, String propertyKey, Class<T> enumType) { String enumName = getStringProperty(properties,propertyKey); Validate.argumentIsNotNull(enumType); try { return Enum.valueOf(enumType, enumName); } catch (IllegalArgumentException e) { throw new JaversException(MALFORMED_PROPERTY, enumName, propertyKey); } }
Example #29
Source File: PerfTicketDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void __testuseCase4_3networkServer() throws Exception { getLogWriter().info("Testing with 3 n/w server ............"); // start a locator final InetAddress localHost = SocketCreator.getLocalHost(); final Properties locProps = new Properties(); setCommonTestProperties(locProps); setCommonProperties(locProps, 0, null, null); locProps.remove("locators"); netPort = AvailablePort .getRandomAvailablePort(AvailablePort.SOCKET); // also start a network server int locPort = TestUtil.startLocator(localHost.getHostAddress(), netPort, locProps); final Properties serverProps = new Properties(); serverProps.setProperty("locators", localHost.getHostName() + '[' + locPort + ']'); setCommonTestProperties(serverProps); startServerVMs(3, 0, null, serverProps); startNetworkServer(3, null, null); startNetworkServer(2, null, null); startNetworkServer(1, null, null); Connection conn = TestUtil.getNetConnection(netPort, null, null); Thread.sleep(2000); profileuseCase4Queries(conn); conn.close(); getLogWriter().info("Done with 3 n/w server ............"); }
Example #30
Source File: TMDatabaseImpl.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void start() throws SQLException, ClassNotFoundException { String driver = dbConfig.getDriver(); Class.forName(driver); String url = Utils.replaceParams(dbConfig.getDbURL(), metaData); Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), metaData); conn = DriverManager.getConnection(url, prop); // 在 PostgreSQL 中如果使用事务,那么在事务中创建表格会抛出异常。 conn.setAutoCommit(false); }