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);

Source Link

Document

Get a boolean associated with the given configuration key.

Usage

From source file:com.springrts.springls.statistics.Statistics.java

@Override
public void update() {

    Configuration conf = context.getService(Configuration.class);
    boolean recording = conf.getBoolean(ServerConfiguration.STATISTICS_STORE);
    if (recording && ((System.currentTimeMillis() - lastStatisticsUpdate) > saveStatisticsInterval)) {
        saveStatisticsToDisk();/*from ww w.jav a  2 s . c  om*/
    }
}

From source file:com.epam.ngb.cli.app.ConfigurationLoader.java

/**
 * Loads XML configuration file with application commands. This file contains
 * information required for initializing and running commands: type of the command,
 * type of request and URL (for NGB server commands) and any supplementary data
 * @param fullCommand name of the command to load configuration for
 * @return configuration for the specifies command
 */// ww  w .  ja  va  2s.c o  m
public CommandConfiguration loadCommandConfiguration(String fullCommand) {
    Configuration configuration = loadXmlConfiguration(COMMAND_XML_CONFIG);
    String name = configuration.getString(fullCommand + COMMAND_NAME_PROPERTY);
    String url = configuration.getString(fullCommand + COMMAND_URL_PROPERTY);
    String type = configuration.getString(fullCommand + COMMAND_TYPE_PROPERTY);
    boolean secure = false;
    if (configuration.getString(fullCommand + COMMAND_SECURE_PROPERTY) != null) {
        secure = configuration.getBoolean(fullCommand + COMMAND_SECURE_PROPERTY);
    }
    return new CommandConfiguration(name, url, type, secure);
}

From source file:net.handle.servlet.Settings.java

@SuppressWarnings("unchecked")
private void initHandleClientOptions(Configuration configuration) throws SettingsException {
    try {//from   w  ww .j a  v  a  2s . c  om
        preferredProtocols = Protocol.toIntArrayFromList(configuration.getList(PREFERRED_PROTOCOLS_KEY));
        if (preferredProtocols != null && preferredProtocols.length > 0) {
            for (int i : preferredProtocols) {
                LOG.info("Adding preferred protocol '" + Protocol.forInt(i).toString() + "'");
            }
        } else {
            throw new SettingsException(PREFERRED_PROTOCOLS_KEY + " is blank");
        }

        traceMessages = configuration.getBoolean(TRACE_MESSAGES_KEY);
        LOG.info("Setting traceMessages '" + traceMessages + "'");
    } catch (ConversionException e) {
        throw new SettingsException(e);
    }
}

From source file:com.linkedin.pinot.controller.helix.core.rebalance.DefaultRebalanceStrategyTest.java

private void validateIdealStateRealtime(IdealState rebalancedIdealState, int nSegmentsCompleted,
        int nSegmentsConsuming, int targetNumReplicas, List<String> instancesCompleted,
        List<String> instancesConsuming, Configuration rebalanceUserConfig) {
    Assert.assertEquals(rebalancedIdealState.getPartitionSet().size(), nSegmentsCompleted + nSegmentsConsuming);
    for (String segment : rebalancedIdealState.getPartitionSet()) {
        Map<String, String> instanceStateMap = rebalancedIdealState.getInstanceStateMap(segment);
        Assert.assertEquals(instanceStateMap.size(), targetNumReplicas);
        boolean rebalanceConsuming = rebalanceUserConfig
                .getBoolean(RebalanceUserConfigConstants.INCLUDE_CONSUMING);
        if (segment.contains("consuming")) {
            if (rebalanceConsuming) {
                Assert.assertTrue(instancesConsuming.containsAll(instanceStateMap.keySet()));
            }/* w  ww  .  j a v a2  s. c  om*/
        } else {
            Assert.assertTrue(instancesCompleted.containsAll(instanceStateMap.keySet()));
        }
    }
}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.ConnectorFactoryIcfImpl.java

/**
 * Initialize the ICF implementation. Look for all connector bundles, get
 * basic information about them and keep that in memory.
 *///  www.j a  va 2 s  .  co  m
@PostConstruct
public void initialize() {

    // OLD
    // bundleURLs = listBundleJars();
    bundleURLs = new HashSet<URL>();

    Configuration config = midpointConfiguration.getConfiguration("midpoint.icf");

    // Is classpath scan enabled
    if (config.getBoolean("scanClasspath")) {
        // Scan class path
        bundleURLs.addAll(scanClassPathForBundles());
    }

    // Scan all provided directories
    @SuppressWarnings("unchecked")
    List<String> dirs = config.getList("scanDirectory");
    for (String dir : dirs) {
        bundleURLs.addAll(scanDirectory(dir));
    }

    for (URL u : bundleURLs) {
        LOGGER.debug("ICF bundle URL : {}", u);
    }

    connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance();

}

From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java

protected void configureStorm(Configuration conf, Config stormConf) throws IllegalAccessException {
    stormConf.registerSerialization(LogRecord.class);
    //stormConf.registerSerialization(Entity.class);
    stormConf.registerMetricsConsumer(LoggingMetricsConsumer.class);

    for (Iterator<String> iter = conf.getKeys(); iter.hasNext();) {
        String key = iter.next();

        String keyString = key.toString();
        String cleanedKey = keyString.replaceAll("\\.\\.", ".");

        String schemaFieldName = cleanedKey.replaceAll("\\.", "_").toUpperCase() + "_SCHEMA";
        Field field = FieldUtils.getField(Config.class, schemaFieldName);
        Object fieldObject = field.get(null);

        if (fieldObject == Boolean.class)
            stormConf.put(cleanedKey, conf.getBoolean(keyString));
        else if (fieldObject == String.class)
            stormConf.put(cleanedKey, conf.getString(keyString));
        else if (fieldObject == ConfigValidation.DoubleValidator)
            stormConf.put(cleanedKey, conf.getDouble(keyString));
        else if (fieldObject == ConfigValidation.IntegerValidator)
            stormConf.put(cleanedKey, conf.getInt(keyString));
        else if (fieldObject == ConfigValidation.PowerOf2Validator)
            stormConf.put(cleanedKey, conf.getLong(keyString));
        else if (fieldObject == ConfigValidation.StringOrStringListValidator)
            stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString)));
        else if (fieldObject == ConfigValidation.StringsValidator)
            stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString)));
        else {//from w  ww .j a  v  a2 s.  c o m
            logger.error(
                    "{} cannot be configured from XML. Consider configuring in navie storm configuration.");
            throw new UnsupportedOperationException(cleanedKey + " cannot be configured from XML");
        }
    }
}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnectorFactoryConnIdImpl.java

/**
 * Initialize the ICF implementation. Look for all connector bundles, get
 * basic information about them and keep that in memory.
 *///  w w w.j a  va 2s . co m
@PostConstruct
public void initialize() {

    // OLD
    // bundleURIs = listBundleJars();
    bundleURIs = new HashSet<>();

    Configuration config = midpointConfiguration.getConfiguration("midpoint.icf");

    // Is classpath scan enabled
    if (config.getBoolean("scanClasspath")) {
        // Scan class path
        bundleURIs.addAll(scanClassPathForBundles());
    }

    // Scan all provided directories
    @SuppressWarnings("unchecked")
    List<String> dirs = config.getList("scanDirectory");
    for (String dir : dirs) {
        bundleURIs.addAll(scanDirectory(dir));
    }

    for (URI u : bundleURIs) {
        LOGGER.debug("ICF bundle URI : {}", u);
    }

    connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance();

}

From source file:co.turnus.analysis.profiler.orcc.ui.OrccDynamicProfilerLaunchDelegate.java

@Override
public void launch(ILaunchConfiguration launchConfiguration, String mode, ILaunch launch,
        IProgressMonitor monitor) throws CoreException {

    try {//from w  w  w .ja  v a2  s.  c om
        // parse the launch configuration options
        final Configuration configuration = OrccDynamicProfilerOptions.getConfiguration(launchConfiguration,
                mode);

        // build the profiling job
        Job job = new Job("TURNUS Orcc Profiler") {

            private OrccDynamicProfiler profiler;

            @Override
            protected void canceling() {
                OrccLogger.traceln("Simulation stop request sent by user");
                profiler.stop();
            }

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {

                    // launch the profiler
                    profiler = new OrccDynamicProfiler();
                    profiler.setConfiguration(configuration);
                    profiler.start();

                    // load trace project in the workspace
                    try {
                        if (configuration.getBoolean(CREATE_TRACE_PROJECT)) {
                            File out = new File(configuration.getString(OUTPUT_PATH));
                            EclipseHelper.importProjectToWorkspace(out, monitor);
                        }
                    } catch (Exception e) {
                        OrccLogger.warnln("The project can not be imported in your workspace. "
                                + "Probably you already have one with this name");
                    }

                    // refresh the workspace just in case some files have
                    // been created
                    try {
                        EclipseHelper.refreshWorkspace(monitor);
                    } catch (Exception e) {
                        OrccLogger.warnln("Worspace has not been refreshed. "
                                + "If you generated some files you should manually refresh it.");
                    }

                } catch (Exception e) {
                    throw new TurnusRuntimeException(e.getMessage());
                }

                return Status.OK_STATUS;
            }

        };

        // configure process and logger
        OrccProfilerProcess process = new OrccProfilerProcess(job, launch);
        launch.addProcess(process);
        OrccLogger.configureLoggerWithHandler(new OrccUiConsoleHandler(DebugUITools.getConsole(process)),
                new OrccConsoleFormatter());

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

        // Houston we are go
        job.setUser(false);
        job.schedule();

    } catch (Exception e) {
        // Houston we have had a problem
        throw new TurnusRuntimeException("Simulation Error: " + e.getMessage(), e.getCause());
    }

}

From source file:com.springrts.springls.Client.java

public void sendWelcomeMessage() {

    Configuration conf = context.getService(Configuration.class);

    // the welcome messages command-name is hardcoded to TASSERVER
    // XXX maybe change TASSERVER to WELCOME or the like -> protocol change
    sendLine(String.format("TASSERVER %s %s %d %d", conf.getString(ServerConfiguration.LOBBY_PROTOCOL_VERSION),
            conf.getString(ServerConfiguration.ENGINE_VERSION), conf.getInt(ServerConfiguration.NAT_PORT),
            conf.getBoolean(ServerConfiguration.LAN_MODE) ? 1 : 0));
}

From source file:com.nesscomputing.quartz.NessQuartzModule.java

private void configureJob(final String jobName, final Configuration jobConfig) {
    try {//from   w  w w  . j a  va  2 s.c  o m
        final String className = jobConfig.getString("class");
        Preconditions.checkState(className != null, "No class key found (but it existed earlier!");
        final Class<? extends Job> jobClass = Class.forName(className).asSubclass(Job.class);

        // Bind the class. if it needs to be a singleton, annotate accordingly. Do not add
        // in(Scopes.SINGLETON) here, because then it is not possible to undo that.
        bind(jobClass);

        final QuartzJobBinder binder = QuartzJobBinder.bindQuartzJob(binder(), jobClass);
        binder.name(jobName);

        if (jobConfig.containsKey("delay")) {
            binder.delay(parseDuration(jobConfig, "delay"));
        }

        if (jobConfig.containsKey("startTime")) {
            binder.startTime(parseStartTime(jobConfig, "startTime"), new TimeSpan("60s"));
        }

        if (jobConfig.containsKey("repeat")) {
            binder.repeat(parseDuration(jobConfig, "repeat"));
        }

        if (jobConfig.containsKey("group")) {
            binder.group(jobConfig.getString("group"));
        }

        if (jobConfig.containsKey("cronExpression")) {
            binder.cronExpression(jobConfig.getString("cronExpression"));
        }

        if (jobConfig.containsKey("enabled")) {
            binder.enabled(jobConfig.getBoolean("enabled"));
        } else {
            LOG.warn("Found job %s but no key for enabling!", jobName);
        }

        LOG.info("Registered %s", binder);
        binder.register();
    } catch (ClassCastException cce) {
        addError(cce);
    } catch (ClassNotFoundException cnfe) {
        addError(cnfe);
    }
}