List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:com.appeligo.search.messenger.Messenger.java
public Messenger() { Configuration config = ConfigUtils.getMessageConfig(); mailHost = config.getString("smtpServer", "localhost"); password = config.getString("smtpSenderPassword", null); smtpUser = config.getString("smtpUser", null); debug = config.getBoolean("debugMailSender", true); port = config.getInt("smtpPort", 25); maxAttempts = config.getInt("maxMessageAttempts", 2); deleteMessagesOlderThanDays = config.getInt("deleteMessagesOlderThanDays", 7); }
From source file:com.caricah.iotracah.core.worker.DumbWorker.java
/** * <code>configure</code> allows the base system to configure itself by getting * all the settings it requires and storing them internally. The plugin is only expected to * pick the settings it has registered on the configuration file for its particular use. * * @param configuration//from ww w. j a va 2 s . c o m * @throws UnRetriableException */ @Override public void configure(Configuration configuration) throws UnRetriableException { boolean configAnnoymousLoginEnabled = configuration.getBoolean(CORE_CONFIG_WORKER_ANNONYMOUS_LOGIN_ENABLED, CORE_CONFIG_WORKER_ANNONYMOUS_LOGIN_ENABLED_DEFAULT_VALUE); log.debug(" configure : Anonnymous login is configured to be enabled [{}]", configAnnoymousLoginEnabled); setAnnonymousLoginEnabled(configAnnoymousLoginEnabled); String configAnnoymousLoginUsername = configuration.getString(CORE_CONFIG_WORKER_ANNONYMOUS_LOGIN_USERNAME, CORE_CONFIG_ENGINE_WORKER_ANNONYMOUS_LOGIN_USERNAME_DEFAULT_VALUE); log.debug(" configure : Anonnymous login username is configured to be [{}]", configAnnoymousLoginUsername); setAnnonymousLoginUsername(configAnnoymousLoginUsername); String configAnnoymousLoginPassword = configuration.getString(CORE_CONFIG_WORKER_ANNONYMOUS_LOGIN_PASSWORD, CORE_CONFIG_ENGINE_WORKER_ANNONYMOUS_LOGIN_PASSWORD_DEFAULT_VALUE); log.debug(" configure : Anonnymous login password is configured to be [{}]", configAnnoymousLoginPassword); setAnnonymousLoginPassword(configAnnoymousLoginPassword); int keepaliveInSeconds = configuration.getInt(CORE_CONFIG_WORKER_CLIENT_KEEP_ALIVE_IN_SECONDS, CORE_CONFIG_WORKER_CLIENT_KEEP_ALIVE_IN_SECONDS_DEFAULT_VALUE); log.debug(" configure : Keep alive maximum is configured to be [{}]", keepaliveInSeconds); setKeepAliveInSeconds(keepaliveInSeconds); }
From source file:net.sf.jclal.activelearning.querystrategy.AbstractQueryStrategy.java
/** * * @param configuration The configuration object for the Abstract query * strategy./* w ww . j a v a2s. co m*/ *The XML labels supported are: * <ul> * <li> * <b>maximal= boolean</b> * </li> * <li> * <b>wrapper-classifier type= class</b> * <p> * Package: net.sf.jclal.classifier</p> * <p> * Class: All * </p> * </li> * </ul> */ @Override public void configure(Configuration configuration) { // Set max iteration boolean maximalT = configuration.getBoolean("maximal", isMaximal()); setMaximal(maximalT); String wrapperError = "wrapper-classifier type= "; try { // classifier classname String classifierClassname = configuration.getString("wrapper-classifier[@type]"); wrapperError += classifierClassname; // classifier class Class<? extends IClassifier> classifierClass = (Class<? extends IClassifier>) Class .forName(classifierClassname); // classifier instance IClassifier classifierTemp = classifierClass.newInstance(); // Configure classifier (if necessary) if (classifierTemp instanceof IConfigure) { ((IConfigure) classifierTemp).configure(configuration.subset("wrapper-classifier")); } // Add this classifier to the query strategy setClassifier(classifierTemp); } catch (ClassNotFoundException e) { throw new ConfigurationRuntimeException("Illegal classifier classname: " + wrapperError, e); } catch (InstantiationException e) { throw new ConfigurationRuntimeException("Illegal classifier classname: " + wrapperError, e); } catch (IllegalAccessException e) { throw new ConfigurationRuntimeException("Illegal classifier classname: " + wrapperError, e); } }
From source file:com.evolveum.midpoint.wf.impl.WfConfiguration.java
@PostConstruct void initialize() { Configuration c = midpointConfiguration.getConfiguration(WF_CONFIG_SECTION); checkAllowedKeys(c, KNOWN_KEYS, DEPRECATED_KEYS); enabled = c.getBoolean(KEY_ENABLED, true); if (!enabled) { LOGGER.info("Workflows are disabled."); return;//from w w w.j a va2s. c o m } // activiti properties related to database connection will be taken from SQL repository SqlRepositoryConfiguration sqlConfig = null; String defaultJdbcUrlPrefix = null; try { RepositoryFactory repositoryFactory = (RepositoryFactory) beanFactory.getBean("repositoryFactory"); if (!(repositoryFactory.getFactory() instanceof SqlRepositoryFactory)) { // it may be null as well LOGGER.debug( "SQL configuration cannot be found; Activiti database configuration (if any) will be taken from 'workflow' configuration section only"); if (LOGGER.isTraceEnabled()) { LOGGER.trace("repositoryFactory.getFactory() = " + repositoryFactory); } } else { SqlRepositoryFactory sqlRepositoryFactory = (SqlRepositoryFactory) repositoryFactory.getFactory(); sqlConfig = sqlRepositoryFactory.getSqlConfiguration(); if (sqlConfig.isEmbedded()) { defaultJdbcUrlPrefix = sqlRepositoryFactory.prepareJdbcUrlPrefix(sqlConfig); } } } catch (NoSuchBeanDefinitionException e) { LOGGER.debug( "SqlRepositoryFactory is not available, Activiti database configuration (if any) will be taken from 'workflow' configuration section only."); LOGGER.trace("Reason is", e); } catch (RepositoryServiceFactoryException e) { LoggingUtils.logException(LOGGER, "Cannot determine default JDBC URL for embedded database", e); } String explicitJdbcUrl = c.getString(KEY_JDBC_URL, null); if (explicitJdbcUrl == null) { if (sqlConfig.isEmbedded()) { jdbcUrl = defaultJdbcUrlPrefix + "-activiti;DB_CLOSE_ON_EXIT=FALSE"; } else { jdbcUrl = sqlConfig.getJdbcUrl(); } } else { jdbcUrl = explicitJdbcUrl; } dataSource = c.getString(KEY_DATA_SOURCE, null); if (dataSource == null && explicitJdbcUrl == null) { dataSource = sqlConfig.getDataSource(); // we want to use wf-specific JDBC if there is one (i.e. we do not want to inherit data source from repo in such a case) } if (dataSource != null) { LOGGER.info("Activiti database is at " + dataSource + " (a data source)"); } else { LOGGER.info("Activiti database is at " + jdbcUrl + " (a JDBC URL)"); } activitiSchemaUpdate = c.getBoolean(KEY_ACTIVITI_SCHEMA_UPDATE, true); jdbcDriver = c.getString(KEY_JDBC_DRIVER, sqlConfig != null ? sqlConfig.getDriverClassName() : null); jdbcUser = c.getString(KEY_JDBC_USERNAME, sqlConfig != null ? sqlConfig.getJdbcUsername() : null); jdbcPassword = c.getString(KEY_JDBC_PASSWORD, sqlConfig != null ? sqlConfig.getJdbcPassword() : null); processCheckInterval = c.getInt(KEY_PROCESS_CHECK_INTERVAL, 10); // todo set to bigger default for production use autoDeploymentFrom = c.getStringArray(KEY_AUTO_DEPLOYMENT_FROM); if (autoDeploymentFrom.length == 0) { autoDeploymentFrom = new String[] { AUTO_DEPLOYMENT_FROM_DEFAULT }; } allowApproveOthersItems = c.getBoolean(KEY_ALLOW_APPROVE_OTHERS_ITEMS, false); if (allowApproveOthersItems) { LOGGER.info( "allowApproveOthersItems parameter is set to true, therefore authorized users CAN approve/reject work items assigned to other users."); } // hibernateDialect = sqlConfig != null ? sqlConfig.getHibernateDialect() : ""; validate(); }
From source file:com.feedzai.fos.api.config.FosConfig.java
/** * Creates a new instance of the {@link FosConfig} class. * * @param configuration The base configuration to use. *///w ww. j a v a2s .c om public FosConfig(Configuration configuration) { checkNotNull(configuration, "Configuration cannot be null."); checkArgument(configuration.containsKey(FACTORY_NAME), "The configuration parameter " + FACTORY_NAME + " should be defined."); this.config = configuration; this.embeddedRegistry = configuration.getBoolean(EMBEDDED_REGISTRY, false); this.registryPort = configuration.getInt(REGISTRY_PORT, Registry.REGISTRY_PORT); this.factoryName = configuration.getString(FACTORY_NAME); this.headerLocation = configuration.getString(HEADER_LOCATION, "models"); this.threadPoolSize = configuration.getInt(THREADPOOL_SIZE, 20); this.scoringPort = configuration.getInt(SCORING_PORT, DEFAULT_SCORING_PORT); }
From source file:net.sf.jclal.evaluation.method.FivePerTwoCrossValidation.java
/** * @param configuration//w w w . j ava 2 s.c o m * The configuration of 5X2 cross validation. The XML labels * supported are: * * <ul> * <li><b>stratify= boolean</b></li> * <li><b>num-folds= int</b></li> * </ul> */ @Override public void configure(Configuration configuration) { super.configure(configuration); // Set stratify (default false) boolean stratifyValue = configuration.getBoolean("stratify", stratify); setStratify(stratifyValue); }
From source file:net.sf.jclal.evaluation.method.kFoldCrossValidation.java
/** * @param configuration The configuration of K-Fold cross validation. *The XML labels supported are:/*from w w w .j a va2 s . c o m*/ * * <ul> * <li><b>stratify= boolean</b></li> * <li><b>num-folds= int</b></li> * </ul> */ @Override public void configure(Configuration configuration) { super.configure(configuration); // Set stratify (default false) boolean stratifyValue = configuration.getBoolean("stratify", stratify); setStratify(stratifyValue); // num folds int numFols = configuration.getInt("num-folds", numFolds); if (numFols < 1) { throw new ConfigurationRuntimeException("\n<num-folds>" + numFols + "</num-folds>. " + "num-folds > 0"); } setNumFolds(numFols); }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testBoolean() throws Exception { Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test"); final String key = UUID.randomUUID().toString(); assertThat(config.getProperty(key), nullValue()); config.setProperty(key, true);/*from w w w . j a v a 2 s . co m*/ assertTrue(config.getBoolean(key, false)); assertEquals(config.getBoolean(key, Boolean.FALSE), Boolean.TRUE); config.setProperty(key, false); assertFalse(config.getBoolean(key, true)); assertEquals(config.getBoolean(key, Boolean.TRUE), Boolean.FALSE); }
From source file:com.caricah.iotracah.core.init.ServersInitializer.java
/** * <code>configure</code> allows the initializer to configure its self * Depending on the implementation conditional operation can be allowed * So as to make the system instance more specialized. * <p>// w w w .j av a 2 s.co m * For example: via the configurations the implementation may decide to * shutdown backend services and it just works as a server application to receive * and route requests to the workers which are in turn connected to the backend/datastore servers... * * @param configuration * @throws UnRetriableException */ @Override public void configure(Configuration configuration) throws UnRetriableException { boolean configWorkerEnabled = configuration.getBoolean(CORE_CONFIG_ENGINE_SERVER_IS_ENABLED, CORE_CONFIG_ENGINE_SERVER_IS_ENABLED_DEFAULT_VALUE); log.debug(" configure : The server function is configured to be enabled [{}]", configWorkerEnabled); setServerEngineEnabled(configWorkerEnabled); String executorName = configuration.getString(CORE_CONFIG_DEFAULT_ENGINE_EXCECUTOR_NAME, CORE_CONFIG_DEFAULT_ENGINE_EXCECUTOR_NAME_DEFAULT_VALUE); setExecutorDefaultName(executorName); executorName = configuration.getString(CORE_CONFIG_ENGINE_EXCECUTOR_EVENT_NAME, getExecutorDefaultName()); setExecutorEventerName(executorName); executorName = configuration.getString(CORE_CONFIG_ENGINE_EXCECUTOR_DATASTORE_NAME, getExecutorDefaultName()); setExecutorDatastoreName(executorName); executorName = configuration.getString(CORE_CONFIG_ENGINE_EXCECUTOR_WORKER_NAME, getExecutorDefaultName()); setExecutorWorkerName(executorName); executorName = configuration.getString(CORE_CONFIG_ENGINE_EXCECUTOR_SERVER_NAME, getExecutorDefaultName()); setExecutorServerName(executorName); boolean excecutorClusterSeparated = configuration.getBoolean( CORE_CONFIG_ENGINE_EXCECUTOR_IS_CLUSTER_SEPARATED, CORE_CONFIG_ENGINE_EXCECUTOR_IS_CLUSTER_SEPARATED_DEFAULT_VALUE); setExecutorClusterSeparated(excecutorClusterSeparated); String[] discoveryAddresses = configuration.getStringArray(CORE_CONFIG_ENGINE_CLUSTER_DISCOVERY_ADDRESSES); setDiscoveryAddresses(discoveryAddresses); }
From source file:net.sf.jclal.sampling.supervised.Resample.java
/** * * @param configuration The configuration object for Resample. * The XML labels supported are://from ww w . j a v a2 s . c o m * <ul> * <li><b>no-replacement= boolean</b></li> * <li><b>invert-selection= boolean</b></li> * <li><b>m_BiasToUniformClass= double</b></li> * </ul> */ @Override public void configure(Configuration configuration) { super.configure(configuration); boolean noReplacementT = configuration.getBoolean("no-replacement", noReplacement); setNoReplacement(noReplacementT); boolean invert = configuration.getBoolean("invert-selection", invertSelection); setInvertSelection(invert); double mBias = configuration.getDouble("bias-to-uniform-class", biasToUniformClass); setBiasToUniformClass(mBias); }