Java Code Examples for org.apache.commons.configuration.Configuration#getProperty()
The following examples show how to use
org.apache.commons.configuration.Configuration#getProperty() .
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: AdminResource.java From atlas with Apache License 2.0 | 6 votes |
private String getEditableEntityTypes(Configuration config) { String ret = DEFAULT_EDITABLE_ENTITY_TYPES; if (config != null && config.containsKey(editableEntityTypes)) { Object value = config.getProperty(editableEntityTypes); if (value instanceof String) { ret = (String) value; } else if (value instanceof Collection) { StringBuilder sb = new StringBuilder(); for (Object elem : ((Collection) value)) { if (sb.length() > 0) { sb.append(","); } sb.append(elem.toString()); } ret = sb.toString(); } } return ret; }
Example 2
Source File: GraphSandboxUtil.java From atlas with Apache License 2.0 | 6 votes |
public static boolean useLocalSolr() { boolean ret = false; try { Configuration conf = ApplicationProperties.get(); Object property = conf.getProperty("atlas.graph.index.search.solr.embedded"); if (property != null && property instanceof String) { ret = Boolean.valueOf((String) property); } } catch (AtlasException ignored) { throw new SkipException("useLocalSolr: failed! ", ignored); } return ret; }
Example 3
Source File: JSONEncoderHelper.java From opensoc-streaming with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static JSONObject getJSON(Configuration config) { JSONObject output = new JSONObject(); if (!config.isEmpty()) { Iterator it = config.getKeys(); while (it.hasNext()) { String k = (String) it.next(); // noinspection unchecked String v = (String) config.getProperty(k); output.put(k, v); } } return output; }
Example 4
Source File: AdminResource.java From incubator-atlas with Apache License 2.0 | 6 votes |
private String getEditableEntityTypes(Configuration config) { String ret = DEFAULT_EDITABLE_ENTITY_TYPES; if (config != null && config.containsKey(editableEntityTypes)) { Object value = config.getProperty(editableEntityTypes); if (value instanceof String) { ret = (String) value; } else if (value instanceof Collection) { StringBuilder sb = new StringBuilder(); for (Object elem : ((Collection) value)) { if (sb.length() > 0) { sb.append(","); } sb.append(elem.toString()); } ret = sb.toString(); } } return ret; }
Example 5
Source File: ZkIsolatedBookieEnsemblePlacementPolicy.java From pulsar with Apache License 2.0 | 6 votes |
private ZooKeeperCache getAndSetZkCache(Configuration conf) { ZooKeeperCache zkCache = null; if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) { zkCache = (ZooKeeperCache) conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE); } else { int zkTimeout; String zkServers; if (conf instanceof ClientConfiguration) { zkTimeout = ((ClientConfiguration) conf).getZkTimeout(); zkServers = ((ClientConfiguration) conf).getZkServers(); try { ZooKeeper zkClient = ZooKeeperClient.newBuilder().connectString(zkServers) .sessionTimeoutMs(zkTimeout).build(); zkCache = new ZooKeeperCache("bookies-isolation", zkClient, (int) TimeUnit.MILLISECONDS.toSeconds(zkTimeout)) { }; conf.addProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, zkCache); } catch (Exception e) { LOG.error("Error creating zookeeper client", e); } } else { LOG.error("No zk configurations available"); } } return zkCache; }
Example 6
Source File: MigrationsRunner.java From flux with Apache License 2.0 | 6 votes |
public void migrate(String dbName) { try { Configuration configuration = yamlConfiguration.subset(dbName + ".Hibernate"); Properties properties = new Properties(); properties.put("user", configuration.getProperty("hibernate.connection.username")); properties.put("password", configuration.getProperty("hibernate.connection.password")); Class.forName("com.mysql.jdbc.Driver").newInstance(); String url = (String) configuration.getProperty("hibernate.connection.url"); java.sql.Connection connection = DriverManager.getConnection(url, properties); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection)); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(dbName + "/migrations.xml").getFile()); Liquibase liquibase = new Liquibase(file.getCanonicalPath(), new FileSystemResourceAccessor(), database); liquibase.update(new Contexts()); } catch (Exception e) { System.err.println("Unable to perform database migration."); e.printStackTrace(); } }
Example 7
Source File: MapBasedConfigurationSource.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public boolean isValidSource(Configuration localConfiguration) { if (localConfiguration.getProperty("cse.config.client.serverUri") == null) { return false; } return true; }
Example 8
Source File: DefaultJBakeConfiguration.java From jbake with MIT License | 5 votes |
public Object getAsciidoctorOption(String optionKey) { Configuration subConfig = compositeConfiguration.subset(JBakeProperty.ASCIIDOCTOR_OPTION); Object value = subConfig.getProperty(optionKey); if (value == null) { logger.warn("Cannot find asciidoctor option '{}.{}'", JBakeProperty.ASCIIDOCTOR_OPTION, optionKey); return ""; } return value; }
Example 9
Source File: PinotCrypterFactory.java From incubator-pinot with Apache License 2.0 | 5 votes |
/** * Initializes map of crypter classes at startup time. Will initialize map with lower case simple class names. * @param config * Sample configuration: * class.nooppinotcrypter = org.apache.pinot.core.crypt.NoOpPinotCrypter * nooppinotcrypter.keyMap = sample_key */ public static void init(Configuration config) { // Get schemes and their respective classes Iterator<String> keys = config.subset(CLASS).getKeys(); if (!keys.hasNext()) { LOGGER.info("Did not find any crypter classes in the configuration"); } while (keys.hasNext()) { String key = keys.next(); String className = (String) config.getProperty(CLASS + "." + key); LOGGER.info("Got crypter class name {}, full crypter path {}, starting to initialize", key, className); try { PinotCrypter pinotCrypter = PluginManager.get().createInstance(className); pinotCrypter.init(config.subset(key)); LOGGER.info("Initializing PinotCrypter for scheme {}, classname {}", key, className); _crypterMap.put(key.toLowerCase(), pinotCrypter); } catch (Exception e) { LOGGER.error("Could not instantiate crypter for class {}", className, e); throw new RuntimeException(e); } } if (!_crypterMap.containsKey(NOOP_PINOT_CRYPTER)) { LOGGER.info("NoOpPinotCrypter not configured, adding as default"); _crypterMap.put(NOOP_PINOT_CRYPTER, new NoOpPinotCrypter()); } }
Example 10
Source File: PinotFSFactory.java From incubator-pinot with Apache License 2.0 | 5 votes |
public static void init(Configuration fsConfig) { // Get schemes and their respective classes Iterator<String> keys = fsConfig.subset(CLASS).getKeys(); if (!keys.hasNext()) { LOGGER.info("Did not find any fs classes in the configuration"); } while (keys.hasNext()) { String key = keys.next(); String fsClassName = (String) fsConfig.getProperty(CLASS + "." + key); LOGGER.info("Got scheme {}, classname {}, starting to initialize", key, fsClassName); register(key, fsClassName, fsConfig.subset(key)); } }
Example 11
Source File: ZkBookieRackAffinityMapping.java From pulsar with Apache License 2.0 | 5 votes |
private ZooKeeperDataCache<BookiesRackConfiguration> getAndSetZkCache(Configuration conf) { ZooKeeperCache zkCache = null; if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) { zkCache = (ZooKeeperCache) conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE); } else { int zkTimeout; String zkServers; if (conf instanceof ClientConfiguration) { zkTimeout = ((ClientConfiguration) conf).getZkTimeout(); zkServers = ((ClientConfiguration) conf).getZkServers(); try { ZooKeeper zkClient = ZooKeeperClient.newBuilder().connectString(zkServers) .sessionTimeoutMs(zkTimeout).build(); zkCache = new ZooKeeperCache("bookies-racks", zkClient, (int) TimeUnit.MILLISECONDS.toSeconds(zkTimeout)) { }; conf.addProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, zkCache); } catch (Exception e) { LOG.error("Error creating zookeeper client", e); } } else { LOG.error("No zk configurations available"); } } ZooKeeperDataCache<BookiesRackConfiguration> zkDataCache = getZkBookieRackMappingCache( zkCache); zkDataCache.registerListener(this); return zkDataCache; }
Example 12
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static Object getProperty(Object config, String key) { if (null != config && Configuration.class.isInstance(config)) { Configuration configuration = (Configuration) config; return configuration.getProperty(key); } return null; }
Example 13
Source File: NacosConfigurationSourceImpl.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public boolean isValidSource(Configuration localConfiguration) { if (localConfiguration.getProperty(SERVER_ADDR) == null) { LOGGER.warn("Nacos configuration source is not configured!"); return false; } return true; }
Example 14
Source File: KieConfigurationSourceImpl.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public boolean isValidSource(Configuration localConfiguration) { if (localConfiguration.getProperty(KIE_CONFIG_URL_KEY) == null) { LOGGER.warn("Kie configuration source is not configured!"); return false; } return true; }
Example 15
Source File: ApolloConfigurationSourceImpl.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override public boolean isValidSource(Configuration localConfiguration) { if (localConfiguration.getProperty(APOLLO_CONFIG_URL_KEY) == null) { LOGGER.warn("Apollo configuration source is not configured!"); return false; } return true; }
Example 16
Source File: AtlasJanusGraphDatabase.java From atlas with Apache License 2.0 | 5 votes |
public static boolean isEmbeddedSolr() { boolean ret = false; try { Configuration conf = ApplicationProperties.get(); Object property = conf.getProperty("atlas.graph.index.search.solr.embedded"); if (property != null && property instanceof String) { ret = Boolean.valueOf((String) property); } } catch (AtlasException ignored) { } return ret; }
Example 17
Source File: TestGraphProvider.java From hugegraph with Apache License 2.0 | 5 votes |
@Watched @Override public void clear(Graph graph, Configuration config) throws Exception { TestGraph testGraph = (TestGraph) graph; if (testGraph == null) { return; } String graphName = config.getString(CoreOptions.STORE.name()); if (!testGraph.initedBackend()) { testGraph.close(); } if (testGraph.closed()) { if (this.graphs.get(graphName) == testGraph) { this.graphs.remove(graphName); } return; } // Reset consumers graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.AUTO); graph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); // Ensure tx clean graph.tx().rollback(); // Clear all data Class<?> testClass = (Class<?>) config.getProperty(TEST_CLASS); testGraph.clearAll(testClass.getCanonicalName()); LOG.debug("Clear graph '{}'", graphName); }
Example 18
Source File: TestGraphProvider.java From hugegraph with Apache License 2.0 | 4 votes |
@Watched @Override public Graph openTestGraph(final Configuration config) { String graphName = config.getString(CoreOptions.STORE.name()); Class<?> testClass = (Class<?>) config.getProperty(TEST_CLASS); String testMethod = config.getString(TEST_METHOD); TestGraph testGraph = this.graphs.get(graphName); if (testGraph == null) { this.graphs.putIfAbsent(graphName, this.newTestGraph(config)); } else if (testGraph.closed()) { this.graphs.put(graphName, this.newTestGraph(config)); } testGraph = this.graphs.get(graphName); // Ensure tx clean testGraph.tx().rollback(); // Define property key 'aKey' based on specified type in test name String aKeyType = getAKeyType(testClass, testMethod); if (aKeyType != null) { testGraph.initPropertyKey("aKey", aKeyType); } if (testMethod.equals( "shouldHaveTruncatedStringRepresentationForEdgeProperty")) { testGraph.initPropertyKey("long", "String"); } else { testGraph.initPropertyKey("long", "Long"); } // Basic schema is initiated by default once a graph is open testGraph.initBasicSchema(idStrategy(config), TestGraph.DEFAULT_VL); if (testClass.getName().equals( "org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals")) { testGraph.initEdgeLabelPersonKnowsPerson(); testGraph.initEdgeLabelPersonCreatedSoftware(); } else { testGraph.initEdgeLabelDefaultKnowsDefault(TestGraph.DEFAULT_VL); testGraph.initEdgeLabelDefaultCreatedDefault(TestGraph.DEFAULT_VL); } testGraph.tx().commit(); testGraph.loadedGraph(getIoType(testClass, testMethod)); testGraph.autoPerson(false); testGraph.ioTest(isIoTest(testClass)); Object loadGraph = config.getProperty(LOAD_GRAPH); if (loadGraph != null && !graphName.endsWith(STANDARD)) { this.loadGraphData(testGraph, (LoadGraphWith.GraphData) loadGraph); } // Used for travis ci output log if (LOG_RATE_LIMITER.tryAcquire(1)) { LOG.info("Open graph '{}' for test '{}'", graphName, testMethod); } return testGraph; }