Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

In this page you can find the example usage for java.lang Boolean getBoolean.

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:org.opendaylight.ovsdb.plugin.ConnectionService.java

public void init() {
    ovsdbConnections = new ConcurrentHashMap<String, Connection>();
    int listenPort = defaultOvsdbPort;
    String portString = System.getProperty(OVSDB_LISTENPORT);
    if (portString != null) {
        listenPort = Integer.decode(portString).intValue();
    }/*from ww  w .  j  a v a2  s.  co m*/
    ovsdbListenPort = listenPort;

    // Keep the default value if the property is not set
    if (System.getProperty(OVSDB_AUTOCONFIGURECONTROLLER) != null)
        autoConfigureController = Boolean.getBoolean(OVSDB_AUTOCONFIGURECONTROLLER);
}

From source file:org.yestech.jmlnitrate.bridge.HttpServletBridge.java

/**
 * This method loads all the Configuration information needed for the
 * Bridge to function properly./*from w  ww  . java  2  s.co  m*/
 *
 * @throws Exception If and error happens loading configurations
 */
private void loadConfiguration() throws Exception {
    //configure Debug
    String tdebug = getInitParameter(DEBUG);
    if (tdebug == null || tdebug.equals("")
            || (!tdebug.equalsIgnoreCase("true") && !tdebug.equalsIgnoreCase("false"))) {
        debug = Boolean.getBoolean(DEFAULT_DEBUG);
    } else {
        debug = new Boolean(tdebug).booleanValue();
    }
    configFile = getInitParameter(JMLNITRATE_CONFIG);
}

From source file:org.eclipse.hudson.init.InitialSetup.java

public boolean needsInitSetup() {
    if (initSetupFile.exists()) {
        return false;
    } else {//from  w  w w  .  j  a  v  a2 s  .co m
        if (Boolean.getBoolean("skipInitSetup")) {
            try {
                initSetupFile.write("Hudson 3.0 Initial Setup Done");
            } catch (IOException ex) {
                logger.error(ex.getLocalizedMessage());
            }
            return false;
        } else {
            return true;
        }
    }
}

From source file:org.opennms.netmgt.notifd.XMPPNotificationManager.java

/**
 * <p>Constructor for XMPPNotificationManager.</p>
 *///from   w  ww. j ava  2s.c om
protected XMPPNotificationManager() {
    // mdc may be null when executing via unit tests
    Map<String, String> mdc = Logging.getCopyOfContextMap();
    try {
        if (mdc != null) {
            mdc.put(Logging.PREFIX_KEY, LOG4J_CATEGORY);
        }

        // Load up some properties
        File config = null;
        try {
            config = ConfigFileConstants.getFile(ConfigFileConstants.XMPP_CONFIG_FILE_NAME);
        } catch (IOException e) {
            LOG.warn("{} not readable", ConfigFileConstants.XMPP_CONFIG_FILE_NAME, e);
        }
        if (Boolean.getBoolean("useSystemXMPPConfig") || !config.canRead()) {
            this.props.putAll(System.getProperties());
        } else {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(config);
                this.props.load(fis);
            } catch (FileNotFoundException e) {
                LOG.warn("unable to load {}", config, e);
            } catch (IOException e) {
                LOG.warn("unable to load {}", config, e);
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }

        xmppServer = this.props.getProperty("xmpp.server");
        String xmppServiceName = this.props.getProperty("xmpp.servicename", xmppServer);
        xmppUser = this.props.getProperty("xmpp.user");
        xmppPassword = this.props.getProperty("xmpp.pass");
        xmppPort = Integer.valueOf(this.props.getProperty("xmpp.port", XMPP_PORT));

        ConnectionConfiguration xmppConfig = new ConnectionConfiguration(xmppServer, xmppPort, xmppServiceName);

        boolean debuggerEnabled = Boolean.parseBoolean(props.getProperty("xmpp.debuggerEnabled"));
        xmppConfig.setDebuggerEnabled(debuggerEnabled);

        if (Boolean.parseBoolean(props.getProperty("xmpp.TLSEnabled"))) {
            xmppConfig.setSecurityMode(SecurityMode.enabled);
        } else {
            xmppConfig.setSecurityMode(SecurityMode.disabled);
        }

        if (Boolean.parseBoolean(props.getProperty("xmpp.selfSignedCertificateEnabled"))) {
            try {
                SSLContext ctx = SSLContext.getInstance("TLS");
                ctx.init(null, new TrustManager[] { new LocalSSLTrustManager() }, null);
                xmppConfig.setCustomSSLContext(ctx);
            } catch (NoSuchAlgorithmException | KeyManagementException e) {
                LOG.error("Failed to create a custom SSL context", e);
            }
        }

        // Remove all SALS mechanisms when SASL is disabled
        // There is currently no option to do this on a per-connection basis
        // so we must do it globally.
        if (!Boolean.parseBoolean(props.getProperty("xmpp.SASLEnabled", "true"))) {
            LOG.info("Removing all SALS mechanisms from Smack.");
            SmackConfiguration.removeSaslMechs(SmackConfiguration.getSaslMechs());
        }

        LOG.debug("XMPP Manager connection config: {}", xmppConfig);

        xmpp = new XMPPTCPConnection(xmppConfig);

        // Connect to xmpp server
        connectToServer();
    } finally {
        if (mdc != null) {
            Logging.setContextMap(mdc);
        }
    }
}

From source file:org.apache.juneau.rest.client.RestClient.java

RestClient(PropertyStore propertyStore, CloseableHttpClient httpClient, boolean keepHttpClientOpen,
        Serializer serializer, Parser parser, UrlEncodingSerializer urlEncodingSerializer,
        PartSerializer partSerializer, Map<String, String> headers, List<RestCallInterceptor> interceptors,
        String rootUri, RetryOn retryOn, int retries, long retryInterval, boolean debug,
        ExecutorService executorService, boolean executorServiceShutdownOnClose) {
    super(propertyStore);
    this.httpClient = httpClient;
    this.keepHttpClientOpen = keepHttpClientOpen;
    this.serializer = serializer;
    this.parser = parser;
    this.urlEncodingSerializer = urlEncodingSerializer;
    this.partSerializer = partSerializer;

    Map<String, String> h2 = new ConcurrentHashMap<String, String>(headers);

    this.headers = Collections.unmodifiableMap(h2);
    this.rootUrl = rootUri;
    this.retryOn = retryOn;
    this.retries = retries;
    this.retryInterval = retryInterval;
    this.debug = debug;

    List<RestCallInterceptor> l = new ArrayList<RestCallInterceptor>(interceptors);
    if (debug)/*from   w w  w.j a v  a2s . c o  m*/
        l.add(RestCallLogger.DEFAULT);

    this.interceptors = l.toArray(new RestCallInterceptor[l.size()]);

    if (Boolean.getBoolean("org.apache.juneau.rest.client.RestClient.trackLifecycle"))
        creationStack = Thread.currentThread().getStackTrace();
    else
        creationStack = null;

    this.executorService = executorService;
    this.executorServiceShutdownOnClose = executorServiceShutdownOnClose;
}

From source file:dgw.mt940.db.util.DGWBasicDataSource.java

public static DataSource setupDataSource(String connectURI, String driver, String userName, String password,
        String removeAbandoned, String initSize, String mxSize) {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(driver);/* w  w  w  . j ava2 s  .  co  m*/
    ds.setUrl(connectURI);
    ds.setUsername(userName);
    ds.setPassword(password);
    ds.setUrl(connectURI);
    ds.setAbandonedUsageTracking(Boolean.getBoolean(removeAbandoned));
    ds.setInitialSize(Integer.parseInt(initSize));
    ds.setMaxIdle(Integer.parseInt(mxSize));
    return ds;
}

From source file:org.wisdom.configuration.ConfigurationImpl.java

/**
 * Get a Boolean property or a default value when property cannot be found
 * in any configuration file.//from  ww  w.j a  va 2  s . c o m
 *
 * @param key          the key used in the configuration file.
 * @param defaultValue Default value returned, when value cannot be found in
 *                     configuration.
 * @return the value of the key or the default value.
 */
@Override
public Boolean getBooleanWithDefault(String key, Boolean defaultValue) {
    if (System.getProperty(key) != null) {
        return Boolean.getBoolean(key);
    } else {
        return configuration.getBoolean(key, defaultValue);
    }
}

From source file:ninja.utils.NinjaPropertiesImpl.java

public NinjaPropertiesImpl(NinjaMode ninjaMode, String externalConfigurationPath) {

    this.ninjaMode = ninjaMode;

    // This is our main configuration.
    // In the following we'll read the individual configurations and merge
    // them into the composite configuration at the end.
    compositeConfiguration = new CompositeConfiguration();

    // That is the default config.
    PropertiesConfiguration defaultConfiguration = null;

    // Config of prefixed mode corresponding to current mode (eg.
    // %test.myproperty=...)
    Configuration prefixedDefaultConfiguration = null;

    // (Optional) Config set via a system property
    PropertiesConfiguration externalConfiguration = null;

    // (Optional) Config of prefixed mode corresponding to current mode (eg.
    // %test.myproperty=...)
    Configuration prefixedExternalConfiguration = null;

    // First step => load application.conf and also merge properties that
    // correspond to a mode into the configuration.

    defaultConfiguration = SwissKnife.loadConfigurationInUtf8(NinjaProperties.CONF_FILE_LOCATION_BY_CONVENTION);

    if (defaultConfiguration != null) {
        // Second step:
        // Copy special prefix of mode to parent configuration
        // By convention it will be something like %test.myproperty
        prefixedDefaultConfiguration = defaultConfiguration.subset("%" + ninjaMode.name());

        // allow application.conf to be reloaded on changes in dev mode
        if (NinjaMode.dev == ninjaMode) {
            defaultConfiguration.setReloadingStrategy(new FileChangedReloadingStrategy());
        }//from w w w . j a v a  2 s  .c  o m

    } else {

        // If the property was set, but the file not found we emit
        // a RuntimeException
        String errorMessage = String.format(
                "Error reading configuration file. Make sure you got a default config file %s",
                NinjaProperties.CONF_FILE_LOCATION_BY_CONVENTION);

        logger.error(errorMessage);

        throw new RuntimeException(errorMessage);
    }

    // third step => load external configuration when a system property is defined.
    String ninjaExternalConf = externalConfigurationPath;

    if (ninjaExternalConf == null) {
        // if not set fallback to system property
        ninjaExternalConf = System.getProperty(NINJA_EXTERNAL_CONF);
    }

    if (ninjaExternalConf != null) {

        // only load it when the property is defined.

        externalConfiguration = SwissKnife.loadConfigurationInUtf8(ninjaExternalConf);

        // this should not happen:
        if (externalConfiguration == null) {

            String errorMessage = String.format(
                    "Ninja was told to use an external configuration%n" + " %s = %s %n."
                            + "But the corresponding file cannot be found.%n"
                            + " Make sure it is visible to this application and on the classpath.",
                    NINJA_EXTERNAL_CONF, ninjaExternalConf);

            logger.error(errorMessage);

            throw new RuntimeException(errorMessage);

        } else {

            // allow the external configuration to be reloaded at
            // runtime based on detected file changes
            final boolean shouldReload = Boolean.getBoolean(NINJA_EXTERNAL_RELOAD);
            if (shouldReload) {
                externalConfiguration.setReloadingStrategy(new FileChangedReloadingStrategy());
            }

            // Copy special prefix of mode to parent configuration
            // By convention it will be something like %test.myproperty
            prefixedExternalConfiguration = externalConfiguration.subset("%" + ninjaMode.name());
        }

    }

    // /////////////////////////////////////////////////////////////////////
    // Finally add the stuff to the composite configuration
    // Note: Configurations added earlier will overwrite configurations
    // added later.
    // /////////////////////////////////////////////////////////////////////

    if (prefixedExternalConfiguration != null) {
        compositeConfiguration.addConfiguration(prefixedExternalConfiguration);
    }

    if (externalConfiguration != null) {
        compositeConfiguration.addConfiguration(externalConfiguration);
    }

    if (prefixedDefaultConfiguration != null) {
        compositeConfiguration.addConfiguration(prefixedDefaultConfiguration);
    }

    if (defaultConfiguration != null) {
        compositeConfiguration.addConfiguration(defaultConfiguration);
    }

    // /////////////////////////////////////////////////////////////////////
    // Check that the secret is set or generate a new one if the property
    // does not exist
    // /////////////////////////////////////////////////////////////////////
    NinjaPropertiesImplTool.checkThatApplicationSecretIsSet(isProd(), new File("").getAbsolutePath(),
            defaultConfiguration, compositeConfiguration);

}

From source file:org.lockss.test.LockssTestCase.java

/**
 * Create and return the name of a temp dir.  The dir is created within
 * the default temp file dir.//from w w  w.j  a va  2s.c om
 * It will be deleted following the test, by tearDown().  (So if you
 * override tearDown(), be sure to call <code>super.tearDown()</code>.)
 * @return The newly created directory
 * @throws IOException
 */
public File getTempDir() throws IOException {
    File res = getTempDir("locksstest");
    // To aid in finding the cause of temp dirs that don't get deleted,
    // setting -Dorg.lockss.test.idTempDirs=true will record the name of
    // the test creating the dir in <dir>/.locksstestcase .  This may cause
    // tests to fail (expecting empty dir).
    if (!isKeepTempFiles() && Boolean.getBoolean("org.lockss.test.idTempDirs")) {
        FileTestUtil.writeFile(new File(res, TEST_ID_FILE_NAME), StringUtil.shortName(this.getClass()));
    }
    return res;
}

From source file:com.hypersocket.server.HypersocketServerImpl.java

@Override
public int getHttpsPort() {
    return Boolean.getBoolean("hypersocket.development") ? 8443
            : configurationService.getIntValue("https.port");
}