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:org.restcomm.connect.telephony.ua.UserAgentManager.java

public UserAgentManager(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();/*from  w w  w.ja v a  2 s .com*/
    // this.configuration = configuration;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.factory = factory;
    this.storage = storage;
    pingInterval = runtime.getInt("ping-interval", 60);
    logger.info("About to run firstTimeCleanup()");
    instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId();
    if (!runtime.subset("ims-authentication").isEmpty()) {
        final Configuration imsAuthentication = runtime.subset("ims-authentication");
        this.actAsImsUa = imsAuthentication.getBoolean("act-as-ims-ua");
        if (actAsImsUa) {
            this.imsProxyAddress = imsAuthentication.getString("proxy-address");
            this.imsProxyPort = imsAuthentication.getInt("proxy-port");
            if (imsProxyPort == 0) {
                imsProxyPort = DEFAUL_IMS_PROXY_PORT;
            }
            this.imsDomain = imsAuthentication.getString("domain");
            if (actAsImsUa && (imsProxyAddress == null || imsProxyAddress.isEmpty() || imsDomain == null
                    || imsDomain.isEmpty())) {
                logger.warning("ims proxy-address or domain is not configured");
            }
            this.actAsImsUa = actAsImsUa && imsProxyAddress != null && !imsProxyAddress.isEmpty()
                    && imsDomain != null && !imsDomain.isEmpty();
        }
    }

    firstTimeCleanup();
}

From source file:org.restcomm.sbc.ConfigurationCache.java

private ConfigurationCache(SipFactory factory, Configuration configuration) {
    sipFactory = factory;/*  w w  w. j  a va2 s . c o m*/
    mzIface = configuration.getString("runtime-settings.militarized-zone.iface-name");
    mzIPAddress = configuration.getString("runtime-settings.militarized-zone.ip-address");
    mzTransport = configuration.getString("runtime-settings.militarized-zone.transport");
    mzPort = configuration.getInt("runtime-settings.militarized-zone.port");

    dmzIface = configuration.getString("runtime-settings.de-militarized-zone.iface-name");
    dmzIPAddress = configuration.getString("runtime-settings.de-militarized-zone.ip-address");
    dmzTransport = configuration.getString("runtime-settings.de-militarized-zone.transport");
    dmzPort = configuration.getInt("runtime-settings.de-militarized-zone.port");

    routeMZIPAddress = configuration
            .getString("runtime-settings.routing-policy.militarized-zone-target.ip-address");
    routeMZTransport = configuration
            .getString("runtime-settings.routing-policy.militarized-zone-target.transport");
    routeMZPort = configuration.getInt("runtime-settings.routing-policy.militarized-zone-target.port");

    regThrottleEnabled = configuration.getBoolean("registrar-throttle.enable");
    regThrottleMinRegistartTTL = configuration.getInt("registrar-throttle.min-registrar-expiration");
    regThrottleMaxUATTL = configuration.getInt("registrar-throttle.max-ua-expiration");

}

From source file:org.seedstack.seed.web.internal.ServerConfigFactory.java

public ServerConfig create(Configuration configuration, SslConfig sslConfig, SSLContext sslContext) {
    ServerConfig serverConfig = new ServerConfig();
    if (configuration.containsKey("host")) {
        serverConfig.setHost(configuration.getString("host"));
    }//from  w w w . j a v  a2s.c  o m
    if (configuration.containsKey("port")) {
        serverConfig.setPort(configuration.getInt("port"));
    }
    if (configuration.containsKey("context-path")) {
        serverConfig.setContextPath(configuration.getString("context-path"));
    }
    if (configuration.containsKey("https-enabled")) {
        serverConfig.setHttpsEnabled(configuration.getBoolean("https-enabled"));
    }
    if (configuration.containsKey("http2-enabled")) {
        serverConfig.setHttp2Enabled(configuration.getBoolean("http2-enabled"));
    }

    // Undertow configuration

    if (configuration.containsKey("buffer-size")) {
        serverConfig.setBufferSize(configuration.getInt("buffer-size"));
    }
    if (configuration.containsKey("buffers-per-region")) {
        serverConfig.setBuffersPerRegion(configuration.getInt("buffers-per-region"));
    }
    if (configuration.containsKey("io-threads")) {
        serverConfig.setIoThreads(configuration.getInt("io-threads"));
    }
    if (configuration.containsKey("worker-threads")) {
        serverConfig.setWorkerThreads(configuration.getInt("worker-threads"));
    }
    if (configuration.containsKey("direct-buffers")) {
        serverConfig.setDirectBuffers(configuration.getBoolean("direct-buffers"));
    }

    serverConfig.setSslConfig(sslConfig);
    serverConfig.setSslContext(sslContext);
    return serverConfig;
}

From source file:org.seedstack.solr.internal.SolrPlugin.java

private SolrClient buildHttpSolrClient(Configuration solrClientConfiguration, String url) {
    HttpSolrClient httpSolrClient = new HttpSolrClient(url);

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.CONNECTION_TIMEOUT)) {
        httpSolrClient.setConnectionTimeout(
                solrClientConfiguration.getInt(SolrConfigurationConstants.CONNECTION_TIMEOUT));
    }/* ww  w . j  a  v  a 2 s  .  c om*/

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.QUERY_PARAMS)) {
        httpSolrClient.setQueryParams(Sets
                .newHashSet(solrClientConfiguration.getStringArray(SolrConfigurationConstants.QUERY_PARAMS)));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.SO_TIMEOUT)) {
        httpSolrClient.setSoTimeout(solrClientConfiguration.getInt(SolrConfigurationConstants.SO_TIMEOUT));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.ALLOW_COMPRESSION)) {
        httpSolrClient.setAllowCompression(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.ALLOW_COMPRESSION));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST)) {
        httpSolrClient.setDefaultMaxConnectionsPerHost(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.FOLLOW_REDIRECTS)) {
        httpSolrClient.setFollowRedirects(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.FOLLOW_REDIRECTS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS)) {
        httpSolrClient.setMaxTotalConnections(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.USE_MULTI_PART_HOST)) {
        httpSolrClient.setUseMultiPartPost(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.USE_MULTI_PART_HOST));
    }

    return httpSolrClient;
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutor.java

/**
 * @see org.sonar.plugins.php.core.PhpPluginAbstractExecutor#getCommandLine()
 *///from  w  ww . j a v a2  s . c  o  m
@Override
protected List<String> getCommandLine() {
    List<String> result = new ArrayList<String>();
    result.add(configuration.getOsDependentToolScriptName());
    Configuration c = configuration.getProject().getConfiguration();
    addBasicOptions(result);

    boolean useMaintTestClass = true;
    if (configuration.isStringPropertySet(PHPUNIT_CONFIGURATION_PROPERTY_KEY)) {
        result.add(PHPUNIT_CONFIGURATION_OPTION + configuration.getConfiguration());
        useMaintTestClass = false;
    }
    addExtendedOptions(result, c);
    if (useMaintTestClass && configuration.isStringPropertySet(PHPUNIT_MAIN_TEST_FILE_PROPERTY_KEY)) {
        result.add(project.getName());
        result.add(configuration.getMainTestClass());
    }
    // source directory is appended phpunit.
    if (!useMaintTestClass || !c.containsKey(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)
            || c.getBoolean(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)) {
        result.add(getTestDirectoryOrFiles());
    }
    return result;
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutor.java

/**
 * @param result//from   ww  w  .j a v a  2 s.  c  o m
 * @param c
 */
private void addExtendedOptions(List<String> result, Configuration c) {
    if (configuration.isStringPropertySet(PHPUNIT_LOADER_PROPERTY_KEY)) {
        result.add(PHPUNIT_LOADER_OPTION + configuration.getLoader());
    }
    if (configuration.isStringPropertySet(PHPUNIT_GROUP_PROPERTY_KEY)) {
        result.add(PHPUNIT_GROUP_OPTION + configuration.getGroup());
    }
    if (configuration.isStringPropertySet(PHPUNIT_ARGUMENT_LINE_KEY)) {
        result.add(configuration.getArgumentLine());
    }
    if (c.containsKey(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)
            && c.getBoolean(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)) {
        result.add(PHPUNIT_IGNORE_CONFIGURATION_OPTION);
    }
    result.add(PHPUNIT_LOG_JUNIT_OPTION + configuration.getReportFile());
    if (configuration.shouldRunCoverage()) {
        result.add(PHPUNIT_COVERAGE_CLOVER_OPTION + configuration.getCoverageReportFile());
    }
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutorTest.java

@Test
public void testIgnoreDefaultConfigurationFile() {
    PhpUnitConfiguration config = mock(PhpUnitConfiguration.class);
    Project project = mock(Project.class);
    MavenProject mProject = mock(MavenProject.class);
    when(project.getPom()).thenReturn(mProject);
    when(mProject.getBasedir()).thenReturn(new File("toto"));

    Configuration configuration = mock(Configuration.class);
    when(project.getConfiguration()).thenReturn(configuration);
    when(config.getProject()).thenReturn(project);

    when(configuration.containsKey(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(true);
    when(configuration.getBoolean(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(true);

    String phpunit = "phpunit";
    when(config.getOsDependentToolScriptName()).thenReturn(phpunit);
    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(project.getFileSystem()).thenReturn(pfs);
    File testDir = new File("c:/php/math-php-test/sources/test");
    when(project.getFileSystem().getTestDirs()).thenReturn(Arrays.asList(testDir));

    PhpUnitExecutor executor = new PhpUnitExecutor(config, project);
    when(config.shouldRunCoverage()).thenReturn(false);
    when(config.getCoverageReportFile()).thenReturn(new File("phpUnit.coverage.xml"));
    File reportFile = new File("phpunit.xml");
    when(config.getReportFile()).thenReturn(reportFile);

    List<String> commandLine = executor.getCommandLine();
    assertThat(commandLine).isNotEmpty();
    assertThat(commandLine).contains(PHPUNIT_IGNORE_CONFIGURATION_OPTION);

    List<String> expected = Arrays.asList(phpunit, "--no-configuration", "--log-junit=" + reportFile,
            testDir.toString());/* w  ww .j  a v a  2  s  . co m*/
    assertThat(commandLine).isEqualTo(expected);
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutorTest.java

@Test
public void testNoIgnoreDefaultConfigurationFile() {
    PhpUnitConfiguration config = mock(PhpUnitConfiguration.class);
    Project project = mock(Project.class);
    MavenProject mProject = mock(MavenProject.class);
    when(project.getPom()).thenReturn(mProject);
    when(mProject.getBasedir()).thenReturn(new File("toto"));

    Configuration configuration = mock(Configuration.class);
    when(project.getConfiguration()).thenReturn(configuration);
    when(config.getProject()).thenReturn(project);

    when(configuration.containsKey(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(false);
    when(configuration.getBoolean(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(true);

    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(project.getFileSystem()).thenReturn(pfs);
    File testDir = new File("c:/php/math-php-test/sources/test");
    when(project.getFileSystem().getTestDirs()).thenReturn(Arrays.asList(testDir));

    PhpUnitExecutor executor = new PhpUnitExecutor(config, project);
    when(config.shouldRunCoverage()).thenReturn(false);
    when(config.getCoverageReportFile()).thenReturn(new File("phpUnit.coverage.xml"));
    List<String> commandLine = executor.getCommandLine();
    assertThat(commandLine).isNotEmpty();
    assertThat(commandLine).excludes(PHPUNIT_IGNORE_CONFIGURATION_OPTION);
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutorTest.java

@Test
public void testAnalyseTestDirectory() {
    PhpUnitConfiguration config = mock(PhpUnitConfiguration.class);
    Project project = mock(Project.class);
    MavenProject mProject = mock(MavenProject.class);
    when(project.getPom()).thenReturn(mProject);
    when(mProject.getBasedir()).thenReturn(new File("toto"));

    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
    when(project.getFileSystem()).thenReturn(pfs);

    Configuration configuration = mock(Configuration.class);
    when(project.getConfiguration()).thenReturn(configuration);
    when(config.getProject()).thenReturn(project);

    when(configuration.containsKey(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(false);
    when(configuration.getBoolean(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(true);

    File testDir = new File("c:/php/math-php-test/sources/test");
    when(project.getFileSystem().getTestDirs()).thenReturn(Arrays.asList(testDir));

    when(configuration.containsKey(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)).thenReturn(true);
    when(configuration.getBoolean(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)).thenReturn(true);

    PhpUnitExecutor executor = new PhpUnitExecutor(config, project);
    when(config.shouldRunCoverage()).thenReturn(false);
    when(config.getCoverageReportFile()).thenReturn(new File("phpUnit.coverage.xml"));
    List<String> commandLine = executor.getCommandLine();
    assertThat(commandLine).isNotEmpty();
    assertThat(commandLine).excludes(PHPUNIT_IGNORE_CONFIGURATION_OPTION);
    assertThat(commandLine).contains(testDir.toString());
}

From source file:org.sonar.plugins.php.phpunit.PhpUnitExecutorTest.java

@Test
public void testDoNotAnalyseTestDirectory() {
    PhpUnitConfiguration config = mock(PhpUnitConfiguration.class);
    Project project = mock(Project.class);
    MavenProject mProject = mock(MavenProject.class);
    when(project.getPom()).thenReturn(mProject);
    when(mProject.getBasedir()).thenReturn(new File("toto"));
    ProjectFileSystem pfs = mock(ProjectFileSystem.class);

    when(project.getFileSystem()).thenReturn(pfs);
    Configuration configuration = mock(Configuration.class);
    when(project.getConfiguration()).thenReturn(configuration);
    when(config.getProject()).thenReturn(project);

    when(configuration.containsKey(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(false);
    when(configuration.getBoolean(PHPUNIT_IGNORE_CONFIGURATION_PROPERTY_KEY)).thenReturn(true);

    when(configuration.containsKey(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)).thenReturn(true);
    when(configuration.getBoolean(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)).thenReturn(false);

    File testDir = new File("c:/php/math-php-test/sources/test");
    when(project.getFileSystem().getTestDirs()).thenReturn(Arrays.asList(testDir));

    PhpUnitExecutor executor = new PhpUnitExecutor(config, project);
    when(config.shouldRunCoverage()).thenReturn(false);
    when(config.getCoverageReportFile()).thenReturn(new File("phpUnit.coverage.xml"));
    List<String> commandLine = executor.getCommandLine();
    assertThat(commandLine).isNotEmpty();
    assertThat(commandLine).excludes(PHPUNIT_IGNORE_CONFIGURATION_OPTION);
    assertThat(commandLine).excludes(testDir.toString());
}