List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:org.apache.juddi.validation.ValidateReplication.java
private synchronized void initDigSig(Configuration config) { if (ds == null) { Properties p = new Properties(); /**//from w ww. j a v a 2s . c o m * <trustStorePath>truststore.jks</trustStorePath> * <trustStoreType>JKS</trustStoreType> * <trustStorePassword * isPasswordEncrypted="false" * cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">password</trustStorePassword> * * <checkTimestamps>true</checkTimestamps> * <checkTrust>true</checkTrust> * <checkRevocationCRL>true</checkRevocationCRL> */ p.put(DigSigUtil.TRUSTSTORE_FILE, config .getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePath", "")); p.put(DigSigUtil.TRUSTSTORE_FILETYPE, config .getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStoreType", "")); String enc = config .getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword", ""); if (config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword[@isPasswordEncrypted]", false)) { log.debug("trust password is encrypted, decrypting..."); String prov = config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword[@cryptoProvider]", ""); try { p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc)); } catch (Exception ex) { log.warn("unable to decrypt trust store password " + ex.getMessage()); log.debug("unable to decrypt trust store password " + ex.getMessage(), ex); } } else if (!"".equals(enc)) { log.warn("Hey, you should consider encrypting your trust store password!"); p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, enc); } p.put(DigSigUtil.CHECK_REVOCATION_STATUS_CRL, config.getString( Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkRevocationCRL", "true")); p.put(DigSigUtil.CHECK_TRUST_CHAIN, config .getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkTrust", "true")); p.put(DigSigUtil.CHECK_TIMESTAMPS, config .getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkTimestamps", "true")); try { ds = new DigSigUtil(p); } catch (CertificateException ex) { log.error("", ex); } //System.out.println("loaded from " + AppConfig.getConfigFileURL()); //p.list(System.out); } }
From source file:org.apache.qpid.server.store.berkeleydb.BDBHAMessageStore.java
@Override public void configure(String name, Configuration storeConfig) throws Exception { //Mandatory configuration _groupName = getValidatedPropertyFromConfig("highAvailability.groupName", storeConfig); _nodeName = getValidatedPropertyFromConfig("highAvailability.nodeName", storeConfig); _nodeHostPort = getValidatedPropertyFromConfig("highAvailability.nodeHostPort", storeConfig); _helperHostPort = getValidatedPropertyFromConfig("highAvailability.helperHostPort", storeConfig); _name = name;//from w w w . jav a 2 s. c o m //Optional configuration String durabilitySetting = storeConfig.getString("highAvailability.durability"); if (durabilitySetting == null) { _durability = DEFAULT_DURABILITY; } else { _durability = Durability.parse(durabilitySetting); } _designatedPrimary = storeConfig.getBoolean("highAvailability.designatedPrimary", Boolean.FALSE); _coalescingSync = storeConfig.getBoolean("highAvailability.coalescingSync", Boolean.TRUE); _repConfig = getConfigMap(REPCONFIG_DEFAULTS, storeConfig, "repConfig"); if (_coalescingSync && _durability.getLocalSync() == SyncPolicy.SYNC) { throw new ConfigurationException( "Coalescing sync cannot be used with master sync policy " + SyncPolicy.SYNC + "! Please set highAvailability.coalescingSync to false in store configuration."); } super.configure(name, storeConfig); }
From source file:org.apache.servicecomb.foundation.vertx.AddressResolverConfig.java
private static boolean getBooleanProperty(Configuration configSource, boolean defaultValue, String... keys) { configSource = guardConfigSource(configSource); if (configSource == null) { return defaultValue; }//from ww w .j a v a 2 s. com for (String key : keys) { Boolean val = configSource.getBoolean(key, null); if (val != null) { return val; } } return defaultValue; }
From source file:org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(EDGE_TRAVERSAL)) { this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph); this.voteScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone()); this.countScope = MessageScope.Local .of(new MessageScope.Local.ReverseTraversalSupplier(this.voteScope)); }/* www. ja v a2 s. c o m*/ this.property = configuration.getString(PROPERTY, CLUSTER); this.maxIterations = configuration.getInt(MAX_ITERATIONS, 30); this.distributeVote = configuration.getBoolean(DISTRIBUTE_VOTE, false); }
From source file:org.apache.tinkerpop.gremlin.spark.structure.io.PersistedOutputRDD.java
@Override public void writeGraphRDD(final Configuration configuration, final JavaPairRDD<Object, VertexWritable> graphRDD) { if (!configuration.getBoolean(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false)) LOGGER.warn(/*from ww w .ja v a2 s . c om*/ "The SparkContext should be persisted in order for the RDD to persist across jobs. To do so, set " + Constants.GREMLIN_SPARK_PERSIST_CONTEXT + " to true"); if (!configuration.containsKey(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION)) throw new IllegalArgumentException("There is no provided " + Constants.GREMLIN_HADOOP_OUTPUT_LOCATION + " to write the persisted RDD to"); SparkContextStorage.open(configuration) .rm(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION)); // this might be bad cause it unpersists the job RDD // determine which storage level to persist the RDD as with MEMORY_ONLY being the default cache() final StorageLevel storageLevel = StorageLevel .fromString(configuration.getString(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_ONLY")); if (!configuration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT_HAS_EDGES, true)) graphRDD.mapValues(vertex -> { vertex.get().dropEdges(Direction.BOTH); return vertex; }).setName( Constants.getGraphLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION))) .persist(storageLevel); else graphRDD.setName( Constants.getGraphLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION))) .persist(storageLevel); Spark.refresh(); // necessary to do really fast so the Spark GC doesn't clear out the RDD }
From source file:org.apache.tinkerpop.gremlin.spark.structure.io.PersistedOutputRDD.java
@Override public <K, V> Iterator<KeyValue<K, V>> writeMemoryRDD(final Configuration configuration, final String memoryKey, final JavaPairRDD<K, V> memoryRDD) { if (!configuration.getBoolean(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false)) LOGGER.warn(//from w w w.j ava2 s .c om "The SparkContext should be persisted in order for the RDD to persist across jobs. To do so, set " + Constants.GREMLIN_SPARK_PERSIST_CONTEXT + " to true"); if (!configuration.containsKey(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION)) throw new IllegalArgumentException("There is no provided " + Constants.GREMLIN_HADOOP_OUTPUT_LOCATION + " to write the persisted RDD to"); final String memoryRDDName = Constants .getMemoryLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION), memoryKey); Spark.removeRDD(memoryRDDName); memoryRDD.setName(memoryRDDName).persist(StorageLevel .fromString(configuration.getString(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_ONLY"))); Spark.refresh(); // necessary to do really fast so the Spark GC doesn't clear out the RDD return IteratorUtils.map(memoryRDD.collect().iterator(), tuple -> new KeyValue<>(tuple._1(), tuple._2())); }
From source file:org.apache.whirr.service.mongodb.BaseMongoDBClusterActionHandler.java
@Override protected void beforeBootstrap(ClusterActionEvent event) throws IOException { ClusterSpec clusterSpec = event.getClusterSpec(); Configuration config = getConfiguration(clusterSpec); addStatement(event,//from w ww . j a v a2 s . c om call("configure_hostnames", MongoDBConstants.PARAM_PROVIDER, clusterSpec.getProvider())); this.noJournal = config.getBoolean(MongoDBConstants.CFG_KEY_NOJOURNAL, null); this.replicaSetName = config.getString(MongoDBConstants.CFG_KEY_REPLSETNAME, null); this.authPassword = config.getString(MongoDBConstants.CFG_KEY_AUTH_PW, null); this.authUsername = config.getString(MongoDBConstants.CFG_KEY_AUTH_USER, null); this.bindIp = config.getString(MongoDBConstants.CFG_KEY_BINDIP, null); this.noPreAlloc = config.getBoolean(MongoDBConstants.CFG_KEY_NOPREALLOC, null); this.smallFiles = config.getBoolean(MongoDBConstants.CFG_KEY_SMALLFILES, null); this.noTableScan = config.getBoolean(MongoDBConstants.CFG_KEY_NOTABLESCAN, null); this.oplogSize = config.getInteger(MongoDBConstants.CFG_KEY_OPLOGSIZE, null); this.nsSize = config.getInteger(MongoDBConstants.CFG_KEY_NSSIZE, null); this.slowMs = config.getInteger(MongoDBConstants.CFG_KEY_SLOWMS, null); this.rest = config.getBoolean(MongoDBConstants.CFG_KEY_REST, null); this.noHttpInterface = config.getBoolean(MongoDBConstants.CFG_KEY_NOHTTP, null); this.journalCommitInterval = config.getInteger(MongoDBConstants.CFG_KEY_JOURNALINTERVAL, null); this.noUnixSockets = config.getBoolean(MongoDBConstants.CFG_KEY_NOUNIX, null); this.objCheck = config.getBoolean(MongoDBConstants.CFG_KEY_OBJCHECK, null); }
From source file:org.apache.wookie.beans.util.PersistenceManagerFactory.java
/** * Initialize factory with configuration. * //from w ww . j av a 2 s.c om * @param configuration configuration properties */ public static void initialize(Configuration configuration) { if (!initialized) { // initialize persistence manager implementation and // initialize persistent store if specified String className = configuration.getString(PERSISTENCE_MANAGER_CLASS_NAME_PROPERTY_NAME, PERSISTENCE_MANAGER_CLASS_NAME_DEFAULT); boolean initializeStore = configuration.getBoolean(PERSISTENCE_MANAGER_INITIALIZE_STORE_PROPERTY_NAME, false); try { persistenceManagerClass = Class.forName(className); Method initializeMethod = persistenceManagerClass.getMethod("initialize", Configuration.class, boolean.class); initializeMethod.invoke(null, configuration, initializeStore); } catch (Exception e) { throw new RuntimeException("Unable to load or initialize PersistenceManager class: " + e, e); } initialized = true; // initialize/verify/validate persistence store using persistence manager try { // allocate and begin persistence manager transaction IPersistenceManager persistenceManager = getPersistenceManager(); persistenceManager.begin(); // Widget boolean initializing = true; IWidget widget = persistenceManager.findWidgetByGuid("http://notsupported"); if (widget == null) { // required: always create if not found widget = persistenceManager.newInstance(IWidget.class); widget.setHeight(350); widget.setWidth(500); widget.setGuid("http://notsupported"); widget.setWidgetAuthor("Paul Sharples"); widget.setWidgetAuthorEmail("p.sharples@bolton.ac.uk"); widget.setWidgetAuthorHref("http://iec.bolton.ac.uk"); widget.setVersion("v1.0"); IName widgetName = persistenceManager.newInstance(IName.class); widgetName.setName("Unsupported widget widget"); widgetName.setShortName("Unsupported"); widget.getNames().add(widgetName); IDescription widgetDescription = persistenceManager.newInstance(IDescription.class); widgetDescription.setContent( "This widget is a placeholder for when no corresponding widget is found for a given type"); widget.getDescriptions().add(widgetDescription); IStartFile widgetStartFile = persistenceManager.newInstance(IStartFile.class); widgetStartFile.setUrl("/wookie/wservices/notsupported/index.htm"); widget.getStartFiles().add(widgetStartFile); IStartFile widgetBUStartFile = persistenceManager.newInstance(IStartFile.class); widgetBUStartFile.setUrl("/wookie/wservices/notsupported/locales/bu/index.htm"); widgetBUStartFile.setLang("bu"); widget.getStartFiles().add(widgetBUStartFile); IStartFile widgetFRStartFile = persistenceManager.newInstance(IStartFile.class); widgetFRStartFile.setUrl("/wookie/wservices/notsupported/locales/fr/index.htm"); widgetFRStartFile.setLang("fr"); widget.getStartFiles().add(widgetFRStartFile); IStartFile widgetENStartFile = persistenceManager.newInstance(IStartFile.class); widgetENStartFile.setUrl("/wookie/wservices/notsupported/locales/en/index.htm"); widgetENStartFile.setLang("en"); widget.getStartFiles().add(widgetENStartFile); IWidgetType widgetType = persistenceManager.newInstance(IWidgetType.class); widgetType.setWidgetContext("unsupported"); widget.getWidgetTypes().add(widgetType); IWidgetIcon widgetIcon = persistenceManager.newInstance(IWidgetIcon.class); widgetIcon.setSrc("/wookie/shared/images/defaultwidget.png"); widgetIcon.setHeight(80); widgetIcon.setWidth(80); widgetIcon.setLang("en"); widget.getWidgetIcons().add(widgetIcon); persistenceManager.save(widget); } else { initializing = false; } // WidgetDefault if (persistenceManager.findWidgetDefaultByType("unsupported") == null) { // required: always create if not found IWidgetDefault widgetDefault = persistenceManager.newInstance(IWidgetDefault.class); widgetDefault.setWidget(widget); widgetDefault.setWidgetContext("unsupported"); persistenceManager.save(widgetDefault); } else { initializing = false; } // WidgetService if (initializing && (persistenceManager.findAll(IWidgetService.class).length == 0)) { // optional: create only if initializing IWidgetService chatWidgetService = persistenceManager.newInstance(IWidgetService.class); chatWidgetService.setServiceName("chat"); persistenceManager.save(chatWidgetService); IWidgetService gamesWidgetService = persistenceManager.newInstance(IWidgetService.class); gamesWidgetService.setServiceName("games"); persistenceManager.save(gamesWidgetService); IWidgetService votingWidgetService = persistenceManager.newInstance(IWidgetService.class); votingWidgetService.setServiceName("voting"); persistenceManager.save(votingWidgetService); IWidgetService weatherWidgetService = persistenceManager.newInstance(IWidgetService.class); weatherWidgetService.setServiceName("weather"); persistenceManager.save(weatherWidgetService); } else { initializing = false; } if (persistenceManager.findByValue(IWidgetService.class, "serviceName", "unsupported").length == 0) { // required: always create if not found IWidgetService unsupportedWidgetService = persistenceManager.newInstance(IWidgetService.class); unsupportedWidgetService.setServiceName("unsupported"); persistenceManager.save(unsupportedWidgetService); } else { initializing = false; } // Whitelist if (initializing && (persistenceManager.findAll(IWhitelist.class).length == 0)) { // optional: create only if initializing IWhitelist wookieServerWhitelist = persistenceManager.newInstance(IWhitelist.class); wookieServerWhitelist.setfUrl("http://incubator.apache.org/wookie"); persistenceManager.save(wookieServerWhitelist); } else { initializing = false; } if (persistenceManager.findByValue(IWhitelist.class, "fUrl", "http://127.0.0.1").length == 0) { // required: always create if not found IWhitelist localhostIPAddrWhitelist = persistenceManager.newInstance(IWhitelist.class); localhostIPAddrWhitelist.setfUrl("http://127.0.0.1"); persistenceManager.save(localhostIPAddrWhitelist); } else { initializing = false; } if (persistenceManager.findByValue(IWhitelist.class, "fUrl", "http://localhost").length == 0) { // required: always create if not found IWhitelist localhostWhitelist = persistenceManager.newInstance(IWhitelist.class); localhostWhitelist.setfUrl("http://localhost"); persistenceManager.save(localhostWhitelist); } else { initializing = false; } // ApiKey if (initializing && (persistenceManager.findAll(IApiKey.class).length == 0)) { // optional: create only if initializing IApiKey apiKey = persistenceManager.newInstance(IApiKey.class); apiKey.setValue("TEST"); apiKey.setEmail("test@127.0.0.1"); persistenceManager.save(apiKey); } else { initializing = false; } // commit persistence manager transaction try { persistenceManager.commit(); } catch (PersistenceCommitException pce) { throw new RuntimeException("Initialization exception: " + pce, pce); } if (initializing) { logger.info("Initialized persistent store with seed data"); } else { logger.info("Validated persistent store seed data"); } } finally { // close persistence manager transaction closePersistenceManager(); } logger.info("Initialized with " + className); } else { throw new RuntimeException("PersistenceManagerFactory already initialized"); } }
From source file:org.craftercms.engine.util.config.TargetingProperties.java
/** * Returns trues if targeting is enabled. *//*from w w w .j a v a2 s. c o m*/ public static boolean isTargetingEnabled() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(TARGETING_ENABLED_CONFIG_KEY, false); } else { return false; } }
From source file:org.craftercms.engine.util.config.TargetingProperties.java
/** * Returns true if the sub items of folders with the same family of target IDs should be merged (e.g. "en_US" and * "en" are of the same family).//from w w w. jav a 2 s.c o m */ public static boolean isMergeFolders() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(MERGE_FOLDERS_CONFIG_KEY, false); } else { return false; } }