Java Code Examples for org.apache.commons.configuration2.Configuration#getBoolean()
The following examples show how to use
org.apache.commons.configuration2.Configuration#getBoolean() .
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: TinkerGraph.java From tinkerpop with Apache License 2.0 | 6 votes |
/** * An empty private constructor that initializes {@link TinkerGraph}. */ private TinkerGraph(final Configuration configuration) { this.configuration = configuration; vertexIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, Vertex.class); edgeIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, Edge.class); vertexPropertyIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, VertexProperty.class); defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf( configuration.getString(GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.single.name())); allowNullPropertyValues = configuration.getBoolean(GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES, false); graphLocation = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null); graphFormat = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_FORMAT, null); if ((graphLocation != null && null == graphFormat) || (null == graphLocation && graphFormat != null)) throw new IllegalStateException(String.format("The %s and %s must both be specified if either is present", GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_GRAPH_FORMAT)); if (graphLocation != null) loadGraph(); }
Example 2
Source File: PersistedOutputRDD.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public void writeGraphRDD(final Configuration configuration, final JavaPairRDD<Object, VertexWritable> graphRDD) { if (!configuration.getBoolean(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false)) LOGGER.warn("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_WRITER_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) // call action to eager store rdd .count(); else graphRDD.setName(Constants.getGraphLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION))).persist(storageLevel) // call action to eager store rdd .count(); Spark.refresh(); // necessary to do really fast so the Spark GC doesn't clear out the RDD }
Example 3
Source File: AbstractConfigurableAsyncServer.java From james-project with Apache License 2.0 | 6 votes |
/** * Configure the helloName for the given Configuration * * @param handlerConfiguration * @throws ConfigurationException */ protected void configureHelloName(Configuration handlerConfiguration) throws ConfigurationException { String hostName; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException ue) { hostName = "localhost"; } LOGGER.info("{} is running on: {}", getServiceType(), hostName); boolean autodetect = handlerConfiguration.getBoolean(HELLO_NAME + ".[@autodetect]", true); if (autodetect) { helloName = hostName; } else { helloName = handlerConfiguration.getString(HELLO_NAME); if (helloName == null || helloName.trim().length() < 1) { throw new ConfigurationException("Please configure the helloName or use autodetect"); } } LOGGER.info("{} handler hello name is: {}", getServiceType(), helloName); }
Example 4
Source File: JmxConfiguration.java From james-project with Apache License 2.0 | 5 votes |
public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); }
Example 5
Source File: SiteProperties.java From engine with GNU General Public License v3.0 | 5 votes |
/** * Returns true if SPA (Single Page App) mode is enabled. */ public static boolean isSpaEnabled() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(SPA_ENABLED_CONFIG_KEY, false); } else { return false; } }
Example 6
Source File: SiteProperties.java From engine with GNU General Public License v3.0 | 5 votes |
/** * Returns true if the request should be redirected when the targeted URL is different from the current URL. */ public static boolean isRedirectToTargetedUrl() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(REDIRECT_TO_TARGETED_URL_CONFIG_KEY, false); } else { return false; } }
Example 7
Source File: SiteProperties.java From engine with GNU General Public License v3.0 | 5 votes |
/** * 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). */ public static boolean isMergeFolders() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(MERGE_FOLDERS_CONFIG_KEY, false); } else { return false; } }
Example 8
Source File: SiteProperties.java From engine with GNU General Public License v3.0 | 5 votes |
/** * Returns trues if targeting is enabled. */ public static boolean isTargetingEnabled() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(TARGETING_ENABLED_CONFIG_KEY, false); } else { return false; } }
Example 9
Source File: BlobStoreConfiguration.java From james-project with Apache License 2.0 | 5 votes |
static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled); }
Example 10
Source File: WebAdminServerModule.java From james-project with Apache License 2.0 | 5 votes |
private Optional<TlsConfiguration> readHttpsConfiguration(Configuration configurationFile) { boolean enabled = configurationFile.getBoolean("https.enabled", DEFAULT_HTTPS_DISABLED); if (enabled) { return Optional.of(TlsConfiguration.builder() .raw(configurationFile.getString("https.keystore", DEFAULT_NO_KEYSTORE), configurationFile.getString("https.password", DEFAULT_NO_PASSWORD), configurationFile.getString("https.trust.keystore", DEFAULT_NO_TRUST_KEYSTORE), configurationFile.getString("https.trust.password", DEFAULT_NO_TRUST_PASSWORD)) .build()); } return Optional.empty(); }
Example 11
Source File: WebAdminServerModule.java From james-project with Apache License 2.0 | 5 votes |
@Provides @Singleton public AuthenticationFilter providesAuthenticationFilter(PropertiesProvider propertiesProvider, JwtTokenVerifier jwtTokenVerifier) throws Exception { try { Configuration configurationFile = propertiesProvider.getConfiguration("webadmin"); if (configurationFile.getBoolean("jwt.enabled", DEFAULT_JWT_DISABLED)) { return new JwtFilter(jwtTokenVerifier); } return new NoAuthenticationFilter(); } catch (FileNotFoundException e) { return new NoAuthenticationFilter(); } }
Example 12
Source File: PeerPressureVertexProgram.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(INITIAL_VOTE_STRENGTH_TRAVERSAL)) this.initialVoteStrengthTraversal = PureTraversal.loadState(configuration, INITIAL_VOTE_STRENGTH_TRAVERSAL, graph); 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)); } this.property = configuration.getString(PROPERTY, CLUSTER); this.maxIterations = configuration.getInt(MAX_ITERATIONS, 30); this.distributeVote = configuration.getBoolean(DISTRIBUTE_VOTE, false); }
Example 13
Source File: PersistedOutputRDD.java From tinkerpop with Apache License 2.0 | 5 votes |
@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("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"))) // call action to eager store rdd .count(); 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())); }
Example 14
Source File: ElasticSearchMetricReporterModule.java From james-project with Apache License 2.0 | 4 votes |
private boolean isMetricEnable(Configuration propertiesReader) { return propertiesReader.getBoolean("elasticsearch.metrics.reports.enabled", DEFAULT_DISABLE); }
Example 15
Source File: ElasticSearchMailboxConfiguration.java From james-project with Apache License 2.0 | 4 votes |
private static IndexAttachments provideIndexAttachments(Configuration configuration) { if (configuration.getBoolean(ELASTICSEARCH_INDEX_ATTACHMENTS, DEFAULT_INDEX_ATTACHMENTS)) { return IndexAttachments.YES; } return IndexAttachments.NO; }
Example 16
Source File: ShortestPathVertexProgram.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(SOURCE_VERTEX_FILTER)) this.sourceVertexFilterTraversal = PureTraversal.loadState(configuration, SOURCE_VERTEX_FILTER, graph); if (configuration.containsKey(TARGET_VERTEX_FILTER)) this.targetVertexFilterTraversal = PureTraversal.loadState(configuration, TARGET_VERTEX_FILTER, graph); if (configuration.containsKey(EDGE_TRAVERSAL)) this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph); if (configuration.containsKey(DISTANCE_TRAVERSAL)) this.distanceTraversal = PureTraversal.loadState(configuration, DISTANCE_TRAVERSAL, graph); if (configuration.containsKey(MAX_DISTANCE)) this.maxDistance = (Number) configuration.getProperty(MAX_DISTANCE); this.distanceEqualsNumberOfHops = this.distanceTraversal.equals(DEFAULT_DISTANCE_TRAVERSAL); this.includeEdges = configuration.getBoolean(INCLUDE_EDGES, false); this.standalone = !configuration.containsKey(VertexProgramStep.ROOT_TRAVERSAL); if (!this.standalone) { this.traversal = PureTraversal.loadState(configuration, VertexProgramStep.ROOT_TRAVERSAL, graph); final String programStepId = configuration.getString(ProgramVertexProgramStep.STEP_ID); for (final Step step : this.traversal.get().getSteps()) { if (step.getId().equals(programStepId)) { //noinspection unchecked this.programStep = step; break; } } } // restore halted traversers from the configuration and build an index for direct access this.haltedTraversers = TraversalVertexProgram.loadHaltedTraversers(configuration); this.haltedTraversersIndex = new IndexedTraverserSet<>(v -> v); for (final Traverser.Admin<Vertex> traverser : this.haltedTraversers) { this.haltedTraversersIndex.add(traverser.split()); } this.memoryComputeKeys.add(MemoryComputeKey.of(SHORTEST_PATHS, Operator.addAll, true, !standalone)); }
Example 17
Source File: SiteProperties.java From engine with GNU General Public License v3.0 | 3 votes |
/** * Returns true if full content model type conversion should be disabled. * * Up to and including version 2: * Crafter Engine, in the FreeMarker host only, converts model elements based on a suffix type hint, but only for the first level in * the model, and not for _dt. For example, for contentModel.myvalue_i Integer is returned, but for contentModel.repeater.myvalue_i * and contentModel.date_dt a String is returned. In the Groovy host no type of conversion was performed. * * In version 3 onwards, Crafter Engine converts elements with any suffix type hints (including _dt) at at any level in the content * model and for both Freemarker and Groovy hosts. */ public static boolean isDisableFullModelTypeConversion() { Configuration config = ConfigUtils.getCurrentConfig(); if (config != null) { return config.getBoolean(DISABLE_FULL_MODEL_TYPE_CONVERSION_CONFIG_KEY, false); } else { return false; } }