Example usage for org.apache.commons.configuration Configuration getBoolean

List of usage examples for org.apache.commons.configuration Configuration getBoolean

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getBoolean.

Prototype

Boolean getBoolean(String key, Boolean defaultValue);

Source Link

Document

Get a Boolean associated with the given configuration key.

Usage

From source file:net.sf.jclal.sampling.unsupervised.Resample.java

/**
 *
 * @param configuration The configuration object for Resample.
 * /*from   www .  j ava 2s.c  om*/
 * The XML labels supported are:
 * 
 * <ul>
 * <li><b>no-replacement= boolean</b></li>
 * <li><b>invert-selection= boolean</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);
}

From source file:dk.itst.oiosaml.sp.service.SPFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    String homeParam = filterConfig.getServletContext().getInitParameter(Constants.INIT_OIOSAML_HOME);
    log.info(Constants.INIT_OIOSAML_HOME + " set to " + homeParam + " in web.xml");
    if (homeParam == null) {
        homeParam = System.getProperty(SAMLUtil.OIOSAML_HOME);
    }/*from w  ww  .  ja va  2  s  . c  o m*/
    if (homeParam == null) {
        String name = filterConfig.getServletContext().getInitParameter(Constants.INIT_OIOSAML_NAME);
        if (name != null) {
            log.info("Configuring OIOSAML with application name " + name);
            homeParam = System.getProperty("user.home") + "/.oiosaml-" + name;
        }
    }
    log.info("Trying to retrieve configuration from " + homeParam);
    SAMLConfiguration.setHomeProperty(homeParam);

    if (SAMLConfiguration.isConfigured()) {
        try {
            Configuration conf = SAMLConfiguration.getSystemConfiguration();
            if (conf.getBoolean(Constants.PROP_DEVEL_MODE, false)) {
                develMode = new DevelModeImpl();
                setConfiguration(conf);
                setFilterInitialized(true);
                return;
            }
            setRuntimeConfiguration(conf);
            setFilterInitialized(true);
            return;
        } catch (IllegalStateException e) {
            log.error("Unable to configure", e);
        }
    }
    log.info("The parameter " + Constants.INIT_OIOSAML_HOME + " which is set in web.xml to: " + homeParam
            + " is not set to an (existing) directory, or the directory is empty - OIOSAML-J is not configured.");
    setFilterInitialized(false);

}

From source file:co.turnus.analysis.profiler.orcc.dynamic.OrccDynamicProfilerApplication.java

@Override
public Object start(IApplicationContext context) throws Exception {

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = parser.parse(cliOptions,
            (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS));

    if (commandLine.hasOption('h')) {
        printUsage();//from  www . ja  v a2 s  . c o  m
        return IApplication.EXIT_RELAUNCH;
    }

    try {
        Configuration configuration = OrccDynamicProfilerOptions.getConfiguration(commandLine);

        disableAutoBuild();

        // set the log level
        boolean verbose = configuration.getBoolean(VERBOSE, false);
        OrccLogger.setLevel(verbose ? OrccLogger.ALL : OrccLogger.TRACE);

        // build, configure and launch the profiler
        OrccDynamicProfiler profiler = new OrccDynamicProfiler();
        profiler.setConfiguration(configuration);
        profiler.start();

    } catch (CoreException ce) {
        OrccLogger.severeln("Unable to set the workspace properties.");
        restoreAutoBuild();
        return IApplication.EXIT_RELAUNCH;
    } catch (Exception e) {
        OrccLogger.severeln("Something went wrong: " + e.getLocalizedMessage());
        restoreAutoBuild();
        return IApplication.EXIT_RELAUNCH;
    } finally {
        restoreAutoBuild();
    }

    return IApplication.EXIT_OK;
}

From source file:com.evolveum.midpoint.model.impl.controller.SystemConfigurationHandler.java

public void postInit(PrismObject<SystemConfigurationType> systemConfiguration, OperationResult parentResult) {
    SystemConfigurationHolder.setCurrentConfiguration(systemConfiguration.asObjectable());

    Configuration systemConfigFromFile = startupConfiguration
            .getConfiguration(MidpointConfiguration.SYSTEM_CONFIGURATION_SECTION);
    boolean skip = false;
    if (systemConfigFromFile != null) {
        skip = systemConfigFromFile.getBoolean(
                LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, false);
    }/*w  w  w  .  j ava  2 s.co m*/
    if (skip) {
        LOGGER.warn("Skipping application of repository logging configuration because {}=true",
                LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS);
    } else {
        LoggingConfigurationType loggingConfig = ProfilingConfigurationManager
                .checkSystemProfilingConfiguration(systemConfiguration);
        if (loggingConfig != null) {
            applyLoggingConfiguration(loggingConfig, systemConfiguration.asObjectable().getVersion(),
                    parentResult);
            //applyLoggingConfiguration(systemConfiguration.asObjectable().getLogging(), systemConfiguration.asObjectable().getVersion(), parentResult);
        }
    }
}

From source file:com.cisco.oss.foundation.message.RabbitMQMessageConsumer.java

RabbitMQMessageConsumer(String consumerName) {
    try {//from   w ww  . jav  a  2s .  c om
        this.consumerName = consumerName;
        Configuration subset = configuration.subset(consumerName);
        queueName = subset.getString("queue.name");

        String filter = subset.getString("queue.filter", "");
        boolean isDurable = subset.getBoolean("queue.isDurable", true);
        boolean isSubscription = subset.getBoolean("queue.isSubscription", false);
        long expiration = subset.getLong("queue.expiration", 1800000);
        long maxLength = subset.getLong("queue.maxLength", -1);
        boolean deadLetterIsEnabled = subset.getBoolean("queue.deadLetterIsEnabled", true);
        String deadLetterExchangeName = subset.getString("queue.deadLetterExchangeName", DLQ);
        String subscribedTo = isSubscription ? subset.getString("queue.subscribedTo", "") : queueName;
        String exchangeType = isSubscription ? "topic" : "direct";
        try {
            RabbitMQMessagingFactory.INIT_LATCH.await();
        } catch (InterruptedException e) {
            LOGGER.error("error waiting for init to finish: " + e);
        }
        Channel channel = RabbitMQMessagingFactory.getChannel();
        channel.exchangeDeclare(subscribedTo, exchangeType, isDurable, false, false, null);

        Map<String, Object> args = new HashMap<String, Object>();

        if (maxLength > 0) {
            args.put("x-max-length", maxLength);
        }

        if (expiration > 0) {
            args.put("x-message-ttl", expiration);
        }

        if (deadLetterIsEnabled) {
            channel.exchangeDeclare(deadLetterExchangeName, exchangeType, true, false, false, null);
            args.put("x-dead-letter-exchange", deadLetterExchangeName);
        }

        String queue = channel.queueDeclare(queueName, isDurable, false, false, args).getQueue();

        Map<String, String> filters = ConfigUtil.parseSimpleArrayAsMap(consumerName + ".queue.filters");
        if (filters != null && !filters.isEmpty()) {
            for (String routingKey : filters.values()) {
                channel.queueBind(queue, subscribedTo, routingKey);
            }
        } else {
            channel.queueBind(queue, subscribedTo, "#");
        }

        consumer = new QueueingConsumer(channel);
        //            channel.basicConsume(queueName, true, consumer);
        LOGGER.info("created rabbitmq consumer: {} on exchange: {}, queue-name: {}", consumerName, subscribedTo,
                queueName);
    } catch (IOException e) {
        throw new QueueException("Can't create consumer: " + e, e);
    }

}

From source file:com.evolveum.midpoint.init.StartupConfiguration.java

@Override
public boolean isSafeMode() {
    Configuration c = getConfiguration(MIDPOINT_SECTION);
    if (c == null) {
        return false; // should not occur
    }/*from   w w  w .  j a  va 2 s. com*/
    return c.getBoolean(SAFE_MODE, false);
}

From source file:com.boozallen.cognition.ingest.storm.spout.StormKafkaSpout.java

SpoutConfig getSpoutConfig(Configuration conf) {
    String zookeeper = conf.getString(ZOOKEEPER);
    String brokerPath = conf.getString(BROKER_PATH);
    String topic = conf.getString(TOPIC);
    String zkRoot = conf.getString(ZK_ROOT);
    String spoutId = conf.getString(SPOUT_ID);
    boolean forceFromStart = conf.getBoolean(FORCE_FROM_START, DEFAULT_FORCE_FROM_START);

    logger.debug("Zookeeper: {}", zookeeper);
    logger.debug("BrokerPath: {}", brokerPath);
    logger.debug("Topic: {}", topic);
    logger.debug("ZkRoot: {}", zkRoot);
    logger.debug("Force From Start: {}", forceFromStart);

    ZkHosts zkHosts;//w w w.ja va  2s . c  om
    if (StringUtils.isBlank(brokerPath)) {
        zkHosts = new ZkHosts(zookeeper);
    } else {
        zkHosts = new ZkHosts(zookeeper, brokerPath);
    }
    SpoutConfig spoutConfig = new SpoutConfig(zkHosts, topic, zkRoot, spoutId);
    spoutConfig.forceFromStart = forceFromStart;
    return spoutConfig;
}

From source file:com.germinus.easyconf.ComponentProperties.java

protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties,
        Object defaultValue) {/*  w  ww  .  j a  v a 2s  .c  om*/
    if (theClass.equals(Float.class)) {
        return properties.getFloat(key, (Float) defaultValue);

    } else if (theClass.equals(Integer.class)) {
        return properties.getInteger(key, (Integer) defaultValue);

    } else if (theClass.equals(String.class)) {
        return properties.getString(key, (String) defaultValue);

    } else if (theClass.equals(Double.class)) {
        return properties.getDouble(key, (Double) defaultValue);

    } else if (theClass.equals(Long.class)) {
        return properties.getLong(key, (Long) defaultValue);

    } else if (theClass.equals(Boolean.class)) {
        return properties.getBoolean(key, (Boolean) defaultValue);

    } else if (theClass.equals(List.class)) {
        return properties.getList(key, (List) defaultValue);

    } else if (theClass.equals(BigInteger.class)) {
        return properties.getBigInteger(key, (BigInteger) defaultValue);

    } else if (theClass.equals(BigDecimal.class)) {
        return properties.getBigDecimal(key, (BigDecimal) defaultValue);

    } else if (theClass.equals(Byte.class)) {
        return properties.getByte(key, (Byte) defaultValue);

    } else if (theClass.equals(Short.class)) {
        return properties.getShort(key, (Short) defaultValue);
    }
    throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties");
}

From source file:com.cisco.oss.foundation.message.HornetQMessageConsumer.java

private String createQueueIfNeeded() {

    Configuration subset = configuration.subset(consumerName);
    queueName = subset.getString("queue.name");

    String filter = subset.getString("queue.filter", "");
    boolean isDurable = subset.getBoolean("queue.isDurable", true);
    boolean isSubscription = subset.getBoolean("queue.isSubscription", false);
    String subscribedTo = isSubscription ? subset.getString("queue.subscribedTo", "") : queueName;

    if (isSubscription) {
        if (StringUtils.isBlank(subscribedTo)) {
            throw new QueueException(
                    "Check Configuration - missing required subscribedTo name for consumerThreadLocal["
                            + consumerName + "] as it is marked as isSubscription=true");
        }/*from   w ww .ja v  a2s.  co  m*/
        //            subscribedTo = "foundation." + subscribedTo;
    }

    if (StringUtils.isBlank(queueName)) {

        String rpmSoftwareName = System.getenv("_RPM_SOFTWARE_NAME");
        String artifactId = System.getenv("_ARTIFACT_ID");
        String componentName = "";

        if (StringUtils.isNoneBlank(rpmSoftwareName)) {
            componentName = rpmSoftwareName;
        } else {
            if (StringUtils.isNoneBlank(artifactId)) {
                componentName = artifactId;
            }
        }

        if (StringUtils.isNoneBlank(componentName)) {
            queueName = componentName + "_" + subscribedTo;
        }

        if (StringUtils.isBlank(queueName)) {
            throw new QueueException(
                    "Check Configuration - missing required queue name for consumerThreadLocal: "
                            + consumerName);
        }
    }

    String realQueueName = /*"foundation." + */queueName;

    boolean queueExists = false;

    for (Pair<ClientSession, SessionFailureListener> clientSessionSessionFailureListenerPair : HornetQMessagingFactory
            .getSession(FoundationQueueConsumerFailureListener.class)) {
        ClientSession clientSession = clientSessionSessionFailureListenerPair.getLeft();
        try {
            queueExists = clientSession.queueQuery(new SimpleString(realQueueName)).isExists();
            if (!queueExists) {
                clientSession.createQueue(isSubscription ? subscribedTo : realQueueName, realQueueName, filter,
                        isDurable);
            }
        } catch (HornetQException e) {
            try {
                clientSession.createQueue(isSubscription ? subscribedTo : realQueueName, realQueueName, filter,
                        isDurable);
            } catch (HornetQException e1) {
                throw new QueueException("Can't create queue: " + realQueueName + ". Error: " + e1, e1);
            }
        }
    }

    return realQueueName;

}

From source file:cross.datastructures.fragments.CachedList.java

@Override
public void configure(final Configuration cfg) {
    this.prefetchOnMiss = cfg.getBoolean(this.getClass().getName() + ".prefetchOnMiss", false);
    this.cacheSize = cfg.getInt(this.getClass().getName() + ".cacheSize", 1024);
}