List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:com.cisco.oss.foundation.http.server.jetty.JettyHttpServerFactory.java
/** * @param serviceName - the http logical service name * @param servlets - a mapping between servlet path and servlet instance. This mapping uses the google collections {@link com.google.common.collect.ListMultimap}. * <br>Example of usage: * {@code ArrayListMultimap<String,Servlet> servletMap = ArrayListMultimap.create()} * @param filters - a mapping between filter path and filter instance. This mapping uses the google collections {@link com.google.common.collect.ListMultimap}. * <br>Example of usage: * {@code ArrayListMultimap<String,Filter> filterMap = ArrayListMultimap.create()} * @param eventListeners event listeners to be applied on this server * @param keyStorePath - a path to the keystore file * @param keyStorePassword - the keystore password * @param trustStorePath - the trust store file path * @param trustStorePassword - the trust store password *//*from w w w . j a v a 2 s. c o m*/ @Override public void startHttpServer(String serviceName, ListMultimap<String, Servlet> servlets, ListMultimap<String, Filter> filters, List<EventListener> eventListeners, Map<String, String> initParams, String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword) { if (servers.get(serviceName) != null) { throw new UnsupportedOperationException( "you must first stop stop server: " + serviceName + " before you want to start it again!"); } Configuration configuration = ConfigurationFactory.getConfiguration(); boolean sessionManagerEnabled = configuration.getBoolean(serviceName + ".http.sessionManagerEnabled", false); ContextHandlerCollection handler = new ContextHandlerCollection(); JettyHttpThreadPool jettyHttpThreadPool = new JettyHttpThreadPool(serviceName); Map<String, Map<String, String>> servletMapping = ConfigUtil .parseComplexArrayStructure(serviceName + ".http.servletsMapping"); Map<String, ServletContextHandler> contextMap = new HashMap<>(); int servletNum = -1; for (Map.Entry<String, Servlet> entry : servlets.entries()) { servletNum++; ServletContextHandler context = new ServletContextHandler(); if (sessionManagerEnabled) { context = new ServletContextHandler(ServletContextHandler.SESSIONS); } String uri = entry.getKey(); if (servletMapping != null && !servletMapping.isEmpty()) { contextMap.put(uri, context); } context.setContextPath(configuration.getString(serviceName + ".http.servletContextPath", "/")); if (eventListeners != null && !eventListeners.isEmpty()) { if (servletMapping != null && !servletMapping.isEmpty() && eventListeners.size() == servlets.size()) { context.setEventListeners(new EventListener[] { eventListeners.get(servletNum) }); } else { context.setEventListeners(eventListeners.toArray(new EventListener[0])); } for (EventListener eventListener : JettyHttpServerFactory.eventListeners) { context.addEventListener(eventListener); } } context.addServlet(new ServletHolder(entry.getValue()), uri); for (Map.Entry<String, String> initParam : initParams.entrySet()) { context.setInitParameter(initParam.getKey(), initParam.getValue()); } HttpServerUtil.addFiltersToServletContextHandler(serviceName, jettyHttpThreadPool, context); for (Map.Entry<String, Filter> filterEntry : filters.entries()) { context.addFilter(new FilterHolder(filterEntry.getValue()), filterEntry.getKey(), EnumSet.allOf(DispatcherType.class)); } handler.addHandler(context); } Server server = new Server(); server.setSendServerVersion(false); try { List<Connector> connectors = new ArrayList<>(3); List<String> startupLogs = new ArrayList<>(3); // set connectors String host = configuration.getString(serviceName + ".http.host", "0.0.0.0"); int port = configuration.getInt(serviceName + ".http.port", 8080); int connectionIdleTime = configuration.getInt(serviceName + ".http.connectionIdleTime", 180000); boolean isBlockingChannelConnector = configuration .getBoolean(serviceName + ".http.isBlockingChannelConnector", false); int numberOfAcceptors = configuration.getInt(serviceName + ".http.numberOfAcceptors", Runtime.getRuntime().availableProcessors()); int acceptQueueSize = configuration.getInt(serviceName + ".http.acceptQueueSize", 0); boolean serviceDirectoryEnabled = configuration .getBoolean(serviceName + ".http.serviceDirectory.isEnabled", false); if (servletMapping != null && !servletMapping.isEmpty()) { for (Map<String, String> servletToConnctor : servletMapping.values()) { String logicalName = servletToConnctor.get("logicalName"); String uriMapping = servletToConnctor.get("uriMapping"); String hostForConnector = servletToConnctor.get("host"); int portForConnector = Integer.parseInt(servletToConnctor.get("port")); ServletContextHandler servletContextHandler = contextMap.get(uriMapping); servletContextHandler.setVirtualHosts(new String[] { "@" + logicalName }); boolean isSSL = Boolean.valueOf(servletToConnctor.get("isSSL")); getConnectors(startupLogs, connectors, isSSL, logicalName, serviceName, keyStorePath, keyStorePassword, trustStorePath, trustStorePassword, configuration, hostForConnector, portForConnector, connectionIdleTime, isBlockingChannelConnector, numberOfAcceptors, acceptQueueSize); servletContextHandler.setConnectorNames(new String[] { logicalName }); } } else { boolean useHttpsOnly = configuration.getBoolean(serviceName + ".https.useHttpsOnly", false); getConnectors(startupLogs, connectors, useHttpsOnly, null, serviceName, keyStorePath, keyStorePassword, trustStorePath, trustStorePassword, configuration, host, port, connectionIdleTime, isBlockingChannelConnector, numberOfAcceptors, acceptQueueSize); } server.setConnectors(connectors.toArray(new Connector[0])); // set thread pool server.setThreadPool(jettyHttpThreadPool.threadPool); // set servlets/context handlers server.setHandler(handler); server.start(); ProvidedServiceInstance instance = null; if (serviceDirectoryEnabled) { instance = registerWithSDServer(serviceName, host, port); } servers.put(serviceName, Pair.of(server, instance)); for (String startupLog : startupLogs) { LOGGER.info(startupLog); } // server.join(); } catch (Exception e) { LOGGER.error("Problem starting the http {} server. Error is {}.", new Object[] { serviceName, e, e }); throw new ServerFailedToStartException(e); } }
From source file:com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration.java
public SqlRepositoryConfiguration(Configuration configuration) { setDatabase(configuration.getString(PROPERTY_DATABASE, database)); computeDefaultDatabaseParameters();//from w ww . java 2 s . c o m setAsServer(configuration.getBoolean(PROPERTY_AS_SERVER, embedded)); setBaseDir(configuration.getString(PROPERTY_BASE_DIR, baseDir)); setDriverClassName(configuration.getString(PROPERTY_DRIVER_CLASS_NAME, driverClassName)); setEmbedded(configuration.getBoolean(PROPERTY_EMBEDDED, embedded)); setHibernateDialect(configuration.getString(PROPERTY_HIBERNATE_DIALECT, hibernateDialect)); setHibernateHbm2ddl(configuration.getString(PROPERTY_HIBERNATE_HBM2DDL, hibernateHbm2ddl)); setJdbcPassword(configuration.getString(PROPERTY_JDBC_PASSWORD, jdbcPassword)); setJdbcUrl(configuration.getString(PROPERTY_JDBC_URL, jdbcUrl)); setJdbcUsername(configuration.getString(PROPERTY_JDBC_USERNAME, jdbcUsername)); setPort(configuration.getInt(PROPERTY_PORT, port)); setTcpSSL(configuration.getBoolean(PROPERTY_TCP_SSL, tcpSSL)); setFileName(configuration.getString(PROPERTY_FILE_NAME, fileName)); setDropIfExists(configuration.getBoolean(PROPERTY_DROP_IF_EXISTS, dropIfExists)); setDataSource(configuration.getString(PROPERTY_DATASOURCE, null)); setMinPoolSize(configuration.getInt(PROPERTY_MIN_POOL_SIZE, minPoolSize)); setMaxPoolSize(configuration.getInt(PROPERTY_MAX_POOL_SIZE, maxPoolSize)); setUseZip(configuration.getBoolean(PROPERTY_USE_ZIP, useZip)); computeDefaultConcurrencyParameters(); setTransactionIsolation( configuration.getString(PROPERTY_TRANSACTION_ISOLATION, transactionIsolation.value())); setLockForUpdateViaHibernate( configuration.getBoolean(PROPERTY_LOCK_FOR_UPDATE_VIA_HIBERNATE, lockForUpdateViaHibernate)); setLockForUpdateViaSql(configuration.getBoolean(PROPERTY_LOCK_FOR_UPDATE_VIA_SQL, lockForUpdateViaSql)); setUseReadOnlyTransactions( configuration.getBoolean(PROPERTY_USE_READ_ONLY_TRANSACTIONS, useReadOnlyTransactions)); setPerformanceStatisticsFile( configuration.getString(PROPERTY_PERFORMANCE_STATISTICS_FILE, performanceStatisticsFile)); setPerformanceStatisticsLevel( configuration.getInt(PROPERTY_PERFORMANCE_STATISTICS_LEVEL, performanceStatisticsLevel)); computeDefaultIterativeSearchParameters(); setIterativeSearchByPaging( configuration.getBoolean(PROPERTY_ITERATIVE_SEARCH_BY_PAGING, iterativeSearchByPaging)); setIterativeSearchByPagingBatchSize(configuration.getInt(PROPERTY_ITERATIVE_SEARCH_BY_PAGING_BATCH_SIZE, iterativeSearchByPagingBatchSize)); setIgnoreOrgClosure(configuration.getBoolean(PROPERTY_IGNORE_ORG_CLOSURE, false)); setOrgClosureStartupAction(configuration.getString(PROPERTY_ORG_CLOSURE_STARTUP_ACTION, OrgClosureManager.StartupAction.REBUILD_IF_NEEDED.toString())); setSkipOrgClosureStructureCheck(configuration.getBoolean(PROPERTY_SKIP_ORG_CLOSURE_STRUCTURE_CHECK, false)); setStopOnOrgClosureStartupFailure( configuration.getBoolean(PROPERTY_STOP_ON_ORG_CLOSURE_STARTUP_FAILURE, true)); }
From source file:cross.datastructures.workflow.DefaultWorkflow.java
@Override public void configure(final Configuration cfg) { this.saveHTML = cfg.getBoolean(this.getClass().getName() + ".saveHTML", false); this.saveTEXT = cfg.getBoolean(this.getClass().getName() + ".saveTEXT", false); this.xslPathPrefix = cfg.getString(this.getClass().getName() + ".xslPathPrefix", ""); this.fileFilter = cfg.getString(this.getClass().getName() + ".resultFileFilter", DefaultConfigurableFileFilter.class.getName()); }
From source file:cross.Factory.java
/** * Configures the factory.//from w w w .j a v a 2 s .co m * * @param config1 the configuration to use */ protected void configureMe(final Configuration config1) { EvalTools.notNull(config1, this); this.configuration = new CompositeConfiguration(); this.configuration.addConfiguration(config1); // this.objconfig.addConfigurationListener(this); if (config1.getBoolean("maltcms.ui.charts.PlotRunner.headless", true) == true) { System.setProperty("java.awt.headless", "true"); } configureThreadPool(this.configuration); //initialize CacheFactory Fragments.setDefaultFragmentCacheType(CacheType .valueOf(this.configuration.getString(Fragments.class.getName() + ".cacheType", "EHCACHE"))); // configure ObjectFactory getObjectFactory().configure(config1); getDataSourceFactory().configure(config1); getInputDataFactory().configure(config1); }
From source file:com.knowbout.cc2nlp.server.CCEventServiceImpl.java
/** * Creates listener, optionally wrapping it in a hession endpoint. *///from w w w . java 2 s. co m private KeywordListener getListener() throws Exception { HessianProxyFactory factory = new HessianProxyFactory(); Configuration config = Config.getConfiguration(); if (log.isInfoEnabled()) { log.info("Search endpoint is " + config.getString("searchEndpoint")); } KeywordListener keywordListener = (KeywordListener) factory.create(KeywordListener.class, config.getString("searchEndpoint")); if (config.getBoolean("userAsyncSender", false)) { keywordListener = new SimpleAsychronousKeywordListener(keywordListener); } return keywordListener; }
From source file:de.chaosfisch.uploader.gui.renderer.ProgressNodeRenderer.java
@Inject public ProgressNodeRenderer(final Configuration configuration) { final Label progressInfo = LabelBuilder.create().build(); progressInfo.textProperty().bind(progressBar.progressProperty().multiply(100).asString("%.2f%%")); progressInfo.setAlignment(Pos.CENTER_LEFT); progressInfo.prefWidthProperty().bind(progressBar.widthProperty().subtract(6)); progressEta.alignmentProperty().set(Pos.CENTER_RIGHT); progressEta.prefWidthProperty().bind(progressBar.widthProperty().subtract(6)); progressFinish.alignmentProperty().set(Pos.CENTER_RIGHT); progressFinish.prefWidthProperty().bind(progressBar.widthProperty().subtract(6)); progressFinish.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); progressBytes.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); progressSpeed.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); progressEta.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); getChildren().addAll(progressBar, progressInfo, progressEta, progressSpeed, progressFinish, progressBytes); setOnMouseEntered(new EventHandler<MouseEvent>() { @Override// w ww .ja v a 2 s .co m public void handle(final MouseEvent me) { progressFinish.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); progressBytes.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); progressSpeed.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); progressEta.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); } }); setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(final MouseEvent me) { progressFinish.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); progressBytes.setVisible(configuration.getBoolean(DISPLAY_PROGRESS, false)); progressSpeed.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); progressEta.setVisible(!configuration.getBoolean(DISPLAY_PROGRESS, false)); } }); }
From source file:io.viewserver.core.Utils.java
public static String replaceSystemTokens(String inputString) { String result = inputString;/*from ww w .j ava2s. c o m*/ Pattern pattern = Pattern.compile("%([^%]+)%"); Matcher matcher = pattern.matcher(inputString); while (true) { boolean found = false; while (matcher.find()) { found = true; String token = matcher.group(1); String value = Configuration.getString(token); if (value != null) { boolean encrypted = Configuration.getBoolean(String.format("%s[@%s]", token, PARSE_KEY), false); if (encrypted) { value = parse(value); } result = result.replace(matcher.group(0), value); } } if (!found) { break; } matcher.reset(result); } //only replace single backslashes with double backslashes return result.replaceAll(Matcher.quoteReplacement("(?<!\\)\\(?![\\\"\'])"), Matcher.quoteReplacement("\\\\")); }
From source file:com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph.java
/** * Builds a OrientGraph instance passing a configuration. Supported configuration settings are: * <table>/*from w w w .ja v a 2 s. c o m*/ * <tr> * <td><b>Name</b></td> * <td><b>Description</b></td> * <td><b>Default value</b></td> * </tr> * <tr> * <td>blueprints.orientdb.url</td> * <td>Database URL</td> * <td>-</td> * </tr> * <tr> * <td>blueprints.orientdb.username</td> * <td>User name</td> * <td>admin</td> * </tr> * <tr> * <td>blueprints.orientdb.password</td> * <td>User password</td> * <td>admin</td> * </tr> * <tr> * <td>blueprints.orientdb.saveOriginalIds</td> * <td>Saves the original element IDs by using the property origId. This could be useful on import of graph to preserve original * ids</td> * <td>false</td> * </tr> * <tr> * <td>blueprints.orientdb.keepInMemoryReferences</td> * <td>Avoid to keep records in memory but only RIDs</td> * <td>false</td> * </tr> * <tr> * <td>blueprints.orientdb.useCustomClassesForEdges</td> * <td>Use Edge's label as OrientDB class. If doesn't exist create it under the hood</td> * <td>true</td> * </tr> * <tr> * <td>blueprints.orientdb.useCustomClassesForVertex</td> * <td>Use Vertex's label as OrientDB class. If doesn't exist create it under the hood</td> * <td>true</td> * </tr> * <tr> * <td>blueprints.orientdb.useVertexFieldsForEdgeLabels</td> * <td>Store the edge relationships in vertex by using the Edge's class. This allow to use multiple fields and make faster * traversal by edge's label (class)</td> * <td>true</td> * </tr> * <tr> * <td>blueprints.orientdb.lightweightEdges</td> * <td>Uses lightweight edges. This avoid to create a physical document per edge. Documents are created only when they have * properties</td> * <td>true</td> * </tr> * <tr> * <td>blueprints.orientdb.autoScaleEdgeType</td> * <td>Set auto scale of edge type. True means one edge is managed as LINK, 2 or more are managed with a LINKBAG</td> * <td>false</td> * </tr> * <tr> * <td>blueprints.orientdb.edgeContainerEmbedded2TreeThreshold</td> * <td>Changes the minimum number of edges for edge containers to transform the underlying structure from embedded to tree. Use -1 * to disable transformation</td> * <td>-1</td> * </tr> * <tr> * <td>blueprints.orientdb.edgeContainerTree2EmbeddedThreshold</td> * <td>Changes the minimum number of edges for edge containers to transform the underlying structure from tree to embedded. Use -1 * to disable transformation</td> * <td>-1</td> * </tr> * </table> * * @param configuration * of graph */ protected void init(final Configuration configuration) { final Boolean saveOriginalIds = configuration.getBoolean("blueprints.orientdb.saveOriginalIds", null); if (saveOriginalIds != null) setSaveOriginalIds(saveOriginalIds); final Boolean keepInMemoryReferences = configuration .getBoolean("blueprints.orientdb.keepInMemoryReferences", null); if (keepInMemoryReferences != null) setKeepInMemoryReferences(keepInMemoryReferences); final Boolean useCustomClassesForEdges = configuration .getBoolean("blueprints.orientdb.useCustomClassesForEdges", null); if (useCustomClassesForEdges != null) setUseClassForEdgeLabel(useCustomClassesForEdges); final Boolean useCustomClassesForVertex = configuration .getBoolean("blueprints.orientdb.useCustomClassesForVertex", null); if (useCustomClassesForVertex != null) setUseClassForVertexLabel(useCustomClassesForVertex); final Boolean useVertexFieldsForEdgeLabels = configuration .getBoolean("blueprints.orientdb.useVertexFieldsForEdgeLabels", null); if (useVertexFieldsForEdgeLabels != null) setUseVertexFieldsForEdgeLabels(useVertexFieldsForEdgeLabels); final Boolean lightweightEdges = configuration.getBoolean("blueprints.orientdb.lightweightEdges", null); if (lightweightEdges != null) setUseLightweightEdges(lightweightEdges); final Boolean autoScaleEdgeType = configuration.getBoolean("blueprints.orientdb.autoScaleEdgeType", null); if (autoScaleEdgeType != null) setAutoScaleEdgeType(autoScaleEdgeType); final Boolean requireTransaction = configuration.getBoolean("blueprints.orientdb.requireTransaction", null); if (requireTransaction != null) setRequireTransaction(requireTransaction); }
From source file:com.nesscomputing.quartz.QuartzJob.java
@SuppressWarnings("PMD.UseStringBufferForStringAppends") public void submitConditional(final Scheduler scheduler, @Named(NESS_JOB_NAME) final Configuration nessJobConfiguration) throws SchedulerException { String conditionalKey = null; final boolean enableJob; if (enabled != null) { enableJob = enabled;//w w w . java2 s . c o m } else { if (conditional == null) { enableJob = true; LOG.warn("Neither enable nor conditional was set for %s, enabling unconditionally!", name); } else { conditionalKey = StringUtils.removeStart(conditional, NESS_JOB_NAME + "."); conditionalKey = StringUtils.endsWith(conditionalKey, ".enabled") ? conditionalKey : conditionalKey + ".enabled"; enableJob = nessJobConfiguration.getBoolean(conditionalKey, false); } } if (enableJob) { submit(scheduler); } else { scheduler.addJob(getJobDetail(), false); LOG.info("Job '%s is not scheduled (enabled: %s / conditional: %s)", name, enabled == null ? "<unset>" : enabled.toString(), conditional == null ? "<unset>" : conditionalKey); } }
From source file:keel.Algorithms.Neural_Networks.NNEP_Common.problem.ProblemEvaluator.java
/** * <p>/*from w ww . ja v a 2 s . c om*/ * Configuration parameters for NeuralNetEvaluator are: * * <ul> * <li> * <code>train-data: complex</code></p> * Train data set used in individuals evaluation. * <ul> * <li> * <code>train-data[@file-name] String </code> * File name of train data * </li> * </ul> * </li> * <li> * <code>test-data: complex</code></p> * Test data set used in individuals evaluation. * <ul> * <li> * <code>test-data[@file-name] String </code> * File name of test data * </li> * </ul> * </li> * <li> * <code>[@normalize-data]: boolean (default = false)</code></p> * If this parameter is set to <code>true</true> data sets values are * normalizated after reading their contents * </li> * <li> * <code>[input-interval] (complex)</code></p> * Input interval of normalization. * </li> * <li> * <code>[output-interval] (complex)</code></p> * Output interval of normalization. * </li> * </ul> * <p> * @param settings Configuration object from which the properties are read */ public void configure(Configuration settings) { // Set trainData unscaledTrainData = new DoubleTransposedDataSet(); unscaledTrainData.configure(settings.subset("train-data")); // Set testData unscaledTestData = new DoubleTransposedDataSet(); unscaledTestData.configure(settings.subset("test-data")); // Set normalizer normalizer = new Normalizer(); // Set dataNormalized dataNormalized = settings.getBoolean("[@normalize-data]", false); // Set dataNormalized logTransformation = settings.getBoolean("[@log-input-data]", false); if (dataNormalized) { // Normalization Input Interval Interval interval = new Interval(); // Configure interval interval.configure(settings.subset("input-interval")); // Set interval setInputInterval(interval); // Normalization Output Interval interval = new Interval(); // Configure range interval.configure(settings.subset("output-interval")); // Set interval setOutputInterval(interval); } }