Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#setDelimiterParsingDisabled()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#setDelimiterParsingDisabled() .
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: Properties2HoconConverterTest.java From wisdom with Apache License 2.0 | 6 votes |
public final PropertiesConfiguration loadPropertiesWithApacheConfiguration(File file) { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setEncoding("utf-8"); propertiesConfiguration.setDelimiterParsingDisabled(true); propertiesConfiguration.setFile(file); propertiesConfiguration.setListDelimiter(','); propertiesConfiguration.getLayout().setSingleLine("application.secret", true); try { propertiesConfiguration.load(file); } catch (ConfigurationException e) { return null; } return propertiesConfiguration; }
Example 2
Source File: HugeConfig.java From hugegraph-common with Apache License 2.0 | 6 votes |
private static PropertiesConfiguration loadConfigFile(String path) { E.checkNotNull(path, "config path"); E.checkArgument(!path.isEmpty(), "The config path can't be empty"); File file = new File(path); E.checkArgument(file.exists() && file.isFile() && file.canRead(), "Need to specify a readable config, but got: %s", file.toString()); PropertiesConfiguration config = new PropertiesConfiguration(); config.setDelimiterParsingDisabled(true); try { config.load(file); } catch (ConfigurationException e) { throw new ConfigException("Unable to load config: %s", e, path); } return config; }
Example 3
Source File: RegisterUtil.java From hugegraph with Apache License 2.0 | 6 votes |
public static void registerBackends() { String confFile = "/backend.properties"; InputStream input = RegisterUtil.class.getClass() .getResourceAsStream(confFile); E.checkState(input != null, "Can't read file '%s' as stream", confFile); PropertiesConfiguration props = new PropertiesConfiguration(); props.setDelimiterParsingDisabled(true); try { props.load(input); } catch (ConfigurationException e) { throw new HugeException("Can't load config file: %s", e, confFile); } HugeConfig config = new HugeConfig(props); List<String> backends = config.get(DistOptions.BACKENDS); for (String backend : backends) { registerBackend(backend); } }
Example 4
Source File: DelegatedAccessDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Loads our SQL statements from the appropriate properties file * @param vendor DB vendor string. Must be one of mysql, oracle, hsqldb */ private void initStatements(String vendor) { URL url = getClass().getClassLoader().getResource(vendor + ".properties"); try { statements = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) statements.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads statements.setThrowExceptionOnMissing(true); //throw exception if no prop statements.setDelimiterParsingDisabled(true); //don't split properties statements.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage(), e); return; } }
Example 5
Source File: PropertiesConfigurationWrapper.java From StatsAgg with Apache License 2.0 | 6 votes |
private void readPropertiesConfigurationFile(File propertiesFile) { if (propertiesFile == null) { return; } try { if (propertiesFile.exists()) { configurationDirectory_ = propertiesFile.getParent(); configurationFilename_ = propertiesFile.getName(); propertiesConfiguration_ = new PropertiesConfiguration(); propertiesConfiguration_.setDelimiterParsingDisabled(true); propertiesConfiguration_.setAutoSave(false); propertiesConfiguration_.load(propertiesFile); } } catch (Exception e) { logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); configurationDirectory_ = null; configurationFilename_ = null; propertiesConfiguration_ = null; } }
Example 6
Source File: PropertiesConfigurationWrapper.java From StatsAgg with Apache License 2.0 | 6 votes |
private void readPropertiesConfigurationFile(InputStream configurationInputStream) { if (configurationInputStream == null) { return; } try { configurationInputStream_ = configurationInputStream; propertiesConfiguration_ = new PropertiesConfiguration(); propertiesConfiguration_.setDelimiterParsingDisabled(true); propertiesConfiguration_.setAutoSave(false); propertiesConfiguration_.load(configurationInputStream, null); } catch (Exception e) { logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); configurationInputStream_ = null; propertiesConfiguration_ = null; } }
Example 7
Source File: PropertyPatternMessageColorizer.java From otroslogviewer with Apache License 2.0 | 6 votes |
public void init(InputStream in) throws ConfigurationException { propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setDelimiterParsingDisabled(true); propertiesConfiguration.load(in, "UTF-8"); configuration = new DataConfiguration(propertiesConfiguration); configuration.setDelimiterParsingDisabled(true); String pa = configuration.getString(PROP_PATTERN); int flags = 0; flags = flags | (configuration.getBoolean(PROP_PATTERN_CANON_EQ, false) ? Pattern.CANON_EQ : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_CASE_INSENSITIVE, false) ? Pattern.CASE_INSENSITIVE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_COMMENTS, false) ? Pattern.COMMENTS : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_DOTALL, false) ? Pattern.DOTALL : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_LITERAL, false) ? Pattern.LITERAL : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_MULTILINE, false) ? Pattern.MULTILINE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_UNICODE_CASE, false) ? Pattern.UNICODE_CASE : 0); flags = flags | (configuration.getBoolean(PROP_PATTERN_UNIX_LINES, false) ? Pattern.UNIX_LINES : 0); pattern = Pattern.compile(pa, flags); groupCount = countGroups(pattern); name = configuration.getString(PROP_NAME, "NAME NOT SET!"); description = configuration.getString(PROP_DESCRIPTION, "DESCRIPTION NOT SET!"); testMessage = configuration.getString(PROP_TEST_MESSAGE, ""); }
Example 8
Source File: PullFileLoader.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * Load a {@link Properties} compatible path using fallback as fallback. * @return The {@link Config} in path with fallback as fallback. * @throws IOException */ private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback) throws IOException { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath), Charsets.UTF_8)) { propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils.getBoolean(fallback, PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY)); propertiesConfiguration.load(inputStreamReader); Config configFromProps = ConfigUtils.propertiesToConfig(ConfigurationConverter.getProperties(propertiesConfiguration)); return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString())) .withFallback(configFromProps) .withFallback(fallback); } catch (ConfigurationException ce) { throw new IOException(ce); } }
Example 9
Source File: DelegatedAccessDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Loads our SQL statements from the appropriate properties file * @param vendor DB vendor string. Must be one of mysql, oracle, hsqldb */ private void initStatements(String vendor) { URL url = getClass().getClassLoader().getResource(vendor + ".properties"); try { statements = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) statements.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads statements.setThrowExceptionOnMissing(true); //throw exception if no prop statements.setDelimiterParsingDisabled(true); //don't split properties statements.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage(), e); return; } }
Example 10
Source File: LogConfigUtils.java From singer with Apache License 2.0 | 5 votes |
/** * Converts a Configuration object c to a PropertiesConfiguration by copying all * properties in c into an empty PropertiesConfiguration. * * @return A new PropertiesConfiguration object with all properties from c */ private static PropertiesConfiguration toPropertiesConfiguration(Configuration c) { PropertiesConfiguration p = new PropertiesConfiguration(); p.setDelimiterParsingDisabled(true); for (Iterator<String> it = c.getKeys(); it.hasNext();) { String key = it.next(); String val = c.getString(key); p.setProperty(key, val); } return p; }
Example 11
Source File: SegmentGenerationWithNullValueVectorTest.java From incubator-pinot with Apache License 2.0 | 5 votes |
private void setupQueryServer() throws ConfigurationException { _segmentNames.add(_segment.getSegmentName()); // Mock the instance data manager _serverMetrics = new ServerMetrics(new MetricsRegistry()); TableDataManagerConfig tableDataManagerConfig = mock(TableDataManagerConfig.class); when(tableDataManagerConfig.getTableDataManagerType()).thenReturn("OFFLINE"); when(tableDataManagerConfig.getTableName()).thenReturn(TABLE_NAME); when(tableDataManagerConfig.getDataDir()).thenReturn(FileUtils.getTempDirectoryPath()); @SuppressWarnings("unchecked") TableDataManager tableDataManager = TableDataManagerProvider .getTableDataManager(tableDataManagerConfig, "testInstance", mock(ZkHelixPropertyStore.class), mock(ServerMetrics.class)); tableDataManager.start(); tableDataManager.addSegment(_segment); _instanceDataManager = mock(InstanceDataManager.class); when(_instanceDataManager.getTableDataManager(TABLE_NAME)).thenReturn(tableDataManager); // Set up the query executor URL resourceUrl = getClass().getClassLoader().getResource(QUERY_EXECUTOR_CONFIG_PATH); Assert.assertNotNull(resourceUrl); PropertiesConfiguration queryExecutorConfig = new PropertiesConfiguration(); queryExecutorConfig.setDelimiterParsingDisabled(false); queryExecutorConfig.load(new File(resourceUrl.getFile())); _queryExecutor = new ServerQueryExecutorV1Impl(); _queryExecutor.init(queryExecutorConfig, _instanceDataManager, _serverMetrics); }
Example 12
Source File: TutorialEntityProviderImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private void initConfig() { URL url = getClass().getClassLoader().getResource("Tutorial.config"); try { tutorialProps = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) tutorialProps.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads tutorialProps.setThrowExceptionOnMissing(false); //throw exception if no prop tutorialProps.setDelimiterParsingDisabled(true); //don't split properties tutorialProps.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage()); return; } }
Example 13
Source File: TutorialEntityProviderImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private void initConfig() { URL url = getClass().getClassLoader().getResource("Tutorial.config"); try { tutorialProps = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) tutorialProps.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads tutorialProps.setThrowExceptionOnMissing(false); //throw exception if no prop tutorialProps.setDelimiterParsingDisabled(true); //don't split properties tutorialProps.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage()); return; } }
Example 14
Source File: PropertiesConfigurationWrapper.java From StatsAgg with Apache License 2.0 | 5 votes |
private void readPropertiesConfigurationFile(String filePathAndFilename) { if (filePathAndFilename == null) { return; } try { File propertiesFile = new File(filePathAndFilename); boolean doesFileExist = FileIo.doesFileExist(filePathAndFilename); if (doesFileExist) { configurationDirectory_ = propertiesFile.getParent(); configurationFilename_ = propertiesFile.getName(); propertiesConfiguration_ = new PropertiesConfiguration(); propertiesConfiguration_.setDelimiterParsingDisabled(true); propertiesConfiguration_.setAutoSave(false); propertiesConfiguration_.load(propertiesFile); } } catch (Exception e) { logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e)); configurationDirectory_ = null; configurationFilename_ = null; propertiesConfiguration_ = null; } }
Example 15
Source File: HBaseGraphConfiguration.java From hgraphdb with Apache License 2.0 | 5 votes |
public HBaseGraphConfiguration(Configuration config) { conf = new PropertiesConfiguration(); conf.setDelimiterParsingDisabled(true); conf.setProperty(Keys.GRAPH_CLASS, HBASE_GRAPH_CLASSNAME); if (config != null) { config.getKeys().forEachRemaining(key -> conf.setProperty(key.replace("..", "."), config.getProperty(key))); } }
Example 16
Source File: QueryExecutorTest.java From incubator-pinot with Apache License 2.0 | 4 votes |
@BeforeClass public void setUp() throws Exception { // Set up the segments FileUtils.deleteQuietly(INDEX_DIR); Assert.assertTrue(INDEX_DIR.mkdirs()); URL resourceUrl = getClass().getClassLoader().getResource(AVRO_DATA_PATH); Assert.assertNotNull(resourceUrl); File avroFile = new File(resourceUrl.getFile()); for (int i = 0; i < NUM_SEGMENTS_TO_GENERATE; i++) { SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGeneratorConfigWithoutTimeColumn(avroFile, INDEX_DIR, TABLE_NAME); config.setSegmentNamePostfix(Integer.toString(i)); SegmentIndexCreationDriver driver = new SegmentIndexCreationDriverImpl(); driver.init(config); driver.build(); _indexSegments.add(ImmutableSegmentLoader.load(new File(INDEX_DIR, driver.getSegmentName()), ReadMode.mmap)); _segmentNames.add(driver.getSegmentName()); } // Mock the instance data manager _serverMetrics = new ServerMetrics(new MetricsRegistry()); TableDataManagerConfig tableDataManagerConfig = mock(TableDataManagerConfig.class); when(tableDataManagerConfig.getTableDataManagerType()).thenReturn("OFFLINE"); when(tableDataManagerConfig.getTableName()).thenReturn(TABLE_NAME); when(tableDataManagerConfig.getDataDir()).thenReturn(FileUtils.getTempDirectoryPath()); @SuppressWarnings("unchecked") TableDataManager tableDataManager = TableDataManagerProvider .getTableDataManager(tableDataManagerConfig, "testInstance", mock(ZkHelixPropertyStore.class), mock(ServerMetrics.class)); tableDataManager.start(); for (ImmutableSegment indexSegment : _indexSegments) { tableDataManager.addSegment(indexSegment); } InstanceDataManager instanceDataManager = mock(InstanceDataManager.class); when(instanceDataManager.getTableDataManager(TABLE_NAME)).thenReturn(tableDataManager); // Set up the query executor resourceUrl = getClass().getClassLoader().getResource(QUERY_EXECUTOR_CONFIG_PATH); Assert.assertNotNull(resourceUrl); PropertiesConfiguration queryExecutorConfig = new PropertiesConfiguration(); queryExecutorConfig.setDelimiterParsingDisabled(false); queryExecutorConfig.load(new File(resourceUrl.getFile())); _queryExecutor = new ServerQueryExecutorV1Impl(); _queryExecutor.init(queryExecutorConfig, instanceDataManager, _serverMetrics); }
Example 17
Source File: HBaseGraphConfiguration.java From hgraphdb with Apache License 2.0 | 4 votes |
public HBaseGraphConfiguration() { conf = new PropertiesConfiguration(); conf.setDelimiterParsingDisabled(true); conf.setProperty(Keys.GRAPH_CLASS, HBASE_GRAPH_CLASSNAME); }
Example 18
Source File: LogConfigUtils.java From singer with Apache License 2.0 | 4 votes |
public static SingerLogConfig[] parseLogStreamConfigFromFile(String logConfigFile) throws ConfigurationException { PropertiesConfiguration logConfig = new PropertiesConfiguration(); logConfig.setDelimiterParsingDisabled(true); logConfig.load(new StringReader(logConfigFile)); return parseLogStreamConfig(logConfig); }
Example 19
Source File: ConfigurationUtil.java From keycloak with Apache License 2.0 | 4 votes |
public static PropertiesConfiguration newPropertiesConfiguration(boolean listParsing) { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setDelimiterParsingDisabled(!listParsing); return configuration; }