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:fr.gael.dhus.database.DatabasePostInit.java

/**
 * Run recovery of stopped scanners.//  ww  w .j  a v  a  2  s  . c om
 * WARNING: do never perform Archive.check when recovery is expected. This 
 *    may cause data lost.
 */
private void processUnprocessed() {
    boolean clean_processings = Boolean.getBoolean("Archive.processings.clean");

    logger.info("Archives processing clean instead of recovery "
            + "(Archive.processings.clean) requested by user (" + clean_processings + ")");
    productService.processUnprocessed(!clean_processings);
}

From source file:com.bt.aloha.media.convedia.msml.MsmlRequestParser.java

protected MsmlPromptAndRecordRequest processPromptAndRecordRequest(String target, String commandId,
        Dialogstart dialogstart) {//from  w  ww.  j  a va  2s .  c o  m
    // assume only one Play and Record stanza
    Record record = dialogstart.getRecordArray(0);
    Play play = dialogstart.getPlayArray(0);
    return new MsmlPromptAndRecordRequest(target, dialogstart.getId(),
            new PromptAndRecordCommand(play.getAudioArray(0).getUri(),
                    Boolean.getBoolean(play.getBarge().toString()), record.getDest(), record.isSetAppend(),
                    record.getFormat().toString(), Integer.parseInt(removeSeconds(record.getMaxtime())),
                    Integer.parseInt(removeSeconds(record.getPreSpeech())),
                    Integer.parseInt(removeSeconds(record.getPostSpeech())),
                    record.getTermkey() != null && record.getTermkey().length() > 0
                            ? record.getTermkey().charAt(0)
                            : null));
}

From source file:com.dream.messaging.engine.fixformat.FixformatDataHandler.java

@Override
public Object createValue(Object msgData, Node node) throws DataConvertException {

    Object result = null;/*from  w  ww.ja  va  2s .c  o  m*/

    if (msgData instanceof byte[]) {
        // parser the byte[] to a String which presents the object value
        String clsname = QueryNode.getAttribute(node, ElementAttr.Attr_Class);

        boolean isNumber = this.isNumber(clsname);

        String encoding = (String) this.engine.getProperties().get(FixformatMessageEngine.ENCORDING);
        String type = isNumber ? FixformatMessageEngine.NUMBER : FixformatMessageEngine.TEXT;
        boolean fromLeft = Boolean.getBoolean(
                (String) this.engine.getProperties().get(type + FixformatMessageEngine.START_FROM_LEFT));
        String fillUpWith = (String) this.engine.getProperties()
                .get(type + FixformatMessageEngine.FILL_UP_WITH);

        String aString = null;
        try {
            aString = new String((byte[]) msgData, encoding);
        } catch (UnsupportedEncodingException e) {
            throw new DataConvertException("encoding " + encoding + " is not supported,please check it.", e);
        }

        // remove fill up
        if (fromLeft) {
            aString = StringUtils.stripEnd(aString, fillUpWith);
        } else {
            aString = StringUtils.stripStart(aString, fillUpWith);
        }

        // check if the string empty
        if (StringUtils.isEmpty(aString)) {
            if (isNumber) {
                aString = "0";
            } else {
                aString = "";
            }

            return this.createValue(aString, node);
        }

        if (isNumber) {
            // remove sign
            String sign = "";
            if (aString.equals("+") || aString.equals("-")) {
                aString = aString + "0";
            }
            if (aString.endsWith("+") || aString.endsWith("-")) {
                sign = aString.substring(aString.length() - 1);
                aString = sign + aString.substring(0, aString.length() - 1);
            }

            if (clsname.equalsIgnoreCase(ElementClassType.CLASS_DECIMAL)
                    || clsname.equalsIgnoreCase(ElementClassType.CLASS_FLOAT)
                    || (clsname.equalsIgnoreCase(ElementClassType.CLASS_DOUBLE))) {
                String format = QueryNode.getAttribute(node, ElementAttr.Attr_Format);
                int index = format.indexOf('p');
                if (index < 0) {
                    index = format.indexOf('P');
                }
                int fractionLen = Integer.valueOf(format.substring(index + 1));
                if (aString.length() - fractionLen > 0) {
                    aString = aString.substring(0, aString.length() - fractionLen) + "."
                            + aString.substring(aString.length() - fractionLen);
                } else {
                    StringBuffer sb = new StringBuffer(aString);
                    while (sb.length() < fractionLen) {
                        sb.insert(0, fillUpWith);
                    }
                    aString = sb.toString();
                    aString = "0." + aString;
                }

            }
        }
        result = this.createValue(aString, node);
    } else {
        throw new UnsupportedOperationException("The object for createValue must be a byte array");
    }

    return result;

}

From source file:io.servicecomb.springboot.starter.configuration.CseAutoConfiguration.java

protected void configureArchaius(ConfigurableEnvironmentConfiguration envConfig) {
    if (INITIALIZED.compareAndSet(false, true)) {
        String appName = this.env.getProperty("spring.application.name");
        if (appName == null) {
            appName = "application";
            //log.warn("No spring.application.name found, defaulting to 'application'");
        }// w  w w. j a  v a  2s  .c om
        System.setProperty(DeploymentContext.ContextKey.appId.getKey(), appName);

        ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();

        // support to add other Configurations (Jdbc, DynamoDb, Zookeeper, jclouds,
        // etc...)
        if (this.externalConfigurations != null) {
            for (AbstractConfiguration externalConfig : this.externalConfigurations) {
                config.addConfiguration(externalConfig);
            }
        }
        config.addConfiguration(envConfig, ConfigurableEnvironmentConfiguration.class.getSimpleName());

        // below come from ConfigurationManager.createDefaultConfigInstance()
        DynamicURLConfiguration defaultURLConfig = new DynamicURLConfiguration();
        try {
            config.addConfiguration(defaultURLConfig, URL_CONFIG_NAME);
        } catch (Throwable ex) {
            //log.error("Cannot create config from " + defaultURLConfig, ex);
        }

        // TODO: sys/env above urls?
        if (!Boolean.getBoolean(DISABLE_DEFAULT_SYS_CONFIG)) {
            SystemConfiguration sysConfig = new SystemConfiguration();
            config.addConfiguration(sysConfig, SYS_CONFIG_NAME);
        }
        if (!Boolean.getBoolean(DISABLE_DEFAULT_ENV_CONFIG)) {
            EnvironmentConfiguration environmentConfiguration = new EnvironmentConfiguration();
            config.addConfiguration(environmentConfiguration, ENV_CONFIG_NAME);
        }

        ConcurrentCompositeConfiguration appOverrideConfig = new ConcurrentCompositeConfiguration();
        config.addConfiguration(appOverrideConfig, APPLICATION_PROPERTIES);
        config.setContainerConfigurationIndex(config.getIndexOfConfiguration(appOverrideConfig));

        addArchaiusConfiguration(config);
    }
    //        else {
    //            // TODO: reinstall ConfigurationManager
    //            //log.warn(
    //            //       "Netflix ConfigurationManager has already been installed, unable to re-install");
    //        }
}

From source file:org.eclipse.hudson.plugins.PluginCenter.java

public static boolean disableUpdateCenterSwitch() {
    return Boolean.getBoolean("hudson.pluginManager.disableUpdateCenterSwitch");
}

From source file:org.apache.helix.provisioning.yarn.GenericApplicationMaster.java

/**
 * Parse command line options//from   w w  w .  j  a  v  a 2 s  .com
 * @param args Command line args
 * @return Whether init successful and run should be invoked
 * @throws ParseException
 * @throws IOException
 * @throws YarnException
 */
public boolean start() throws ParseException, IOException, YarnException {

    if (Boolean.getBoolean(System.getenv("debug"))) {
        dumpOutDebugInfo();
    }

    Map<String, String> envs = System.getenv();

    if (!envs.containsKey(ApplicationConstants.APP_SUBMIT_TIME_ENV)) {
        throw new RuntimeException(ApplicationConstants.APP_SUBMIT_TIME_ENV + " not set in the environment");
    }
    if (!envs.containsKey(Environment.NM_HOST.name())) {
        throw new RuntimeException(Environment.NM_HOST.name() + " not set in the environment");
    }
    if (!envs.containsKey(Environment.NM_HTTP_PORT.name())) {
        throw new RuntimeException(Environment.NM_HTTP_PORT + " not set in the environment");
    }
    if (!envs.containsKey(Environment.NM_PORT.name())) {
        throw new RuntimeException(Environment.NM_PORT.name() + " not set in the environment");
    }

    LOG.info("Application master for app" + ", appId=" + appAttemptID.getApplicationId().getId()
            + ", clustertimestamp=" + appAttemptID.getApplicationId().getClusterTimestamp() + ", attemptId="
            + appAttemptID.getAttemptId());

    LOG.info("Starting ApplicationMaster");

    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    LOG.info("Credentials: " + credentials);
    DataOutputBuffer dob = new DataOutputBuffer();
    credentials.writeTokenStorageToStream(dob);
    // Now remove the AM->RM token so that containers cannot access it.
    Iterator<Token<?>> iter = credentials.getAllTokens().iterator();
    while (iter.hasNext()) {
        Token<?> token = iter.next();
        LOG.info("Processing token: " + token);
        if (token.getKind().equals(AMRMTokenIdentifier.KIND_NAME)) {
            iter.remove();
        }
    }
    allTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());

    AMRMClientAsync.CallbackHandler allocListener = new RMCallbackHandler(this);
    amRMClient = AMRMClientAsync.createAMRMClientAsync(1000, allocListener);
    amRMClient.init(conf);
    amRMClient.start();

    containerListener = createNMCallbackHandler();
    nmClientAsync = new NMClientAsyncImpl(containerListener);
    nmClientAsync.init(conf);
    nmClientAsync.start();

    // Setup local RPC Server to accept status requests directly from clients
    // TODO need to setup a protocol for client to be able to communicate to
    // the RPC server
    // TODO use the rpc port info to register with the RM for the client to
    // send requests to this app master

    // Register self with ResourceManager
    // This will start heartbeating to the RM
    appMasterHostname = NetUtils.getHostname();
    RegisterApplicationMasterResponse response = amRMClient.registerApplicationMaster(appMasterHostname,
            appMasterRpcPort, appMasterTrackingUrl);
    // Dump out information about cluster capability as seen by the
    // resource manager
    int maxMem = response.getMaximumResourceCapability().getMemory();
    LOG.info("Max mem capabililty of resources in this cluster " + maxMem);
    return true;
}

From source file:com.adito.agent.client.applications.AgentApplicationLauncher.java

private void processRegistryElements(XMLElement el) {
    if (el.getName().equalsIgnoreCase("get")) {
        String scope = el.getStringAttribute("scope");
        String key = replaceTokens(el.getStringAttribute("key"));
        String value = replaceTokens(el.getStringAttribute("value"));
        String param = replaceTokens(el.getStringAttribute("parameter"));
        String defaultValue = replaceTokens(el.getStringAttribute("default"));

        addParameter(param,/*from  w w w . ja  v  a  2s.  c  o  m*/
                WinRegistry.getRegistryValue(scope, key, value, defaultValue == null ? "" : defaultValue));
    } else if (el.getName().equalsIgnoreCase("set")) {
        String scope = el.getStringAttribute("scope");
        String key = replaceTokens(el.getStringAttribute("key"));
        String value = replaceTokens(el.getStringAttribute("value"));
        String arg = replaceTokens(el.getStringAttribute("arg"));

        WinRegistry.setRegistryValue(scope, key, value, arg);

    } else if (el.getName().equalsIgnoreCase("if")) {

        String scope = el.getStringAttribute("scope");
        String key = replaceTokens(el.getStringAttribute("key"));
        String value = replaceTokens(el.getStringAttribute("value"));
        String notAttr = el.getStringAttribute("not");
        String existsAttr = el.getStringAttribute("exists");
        String equalsAttr = el.getStringAttribute("equals");

        if (existsAttr != null) {
            boolean exists = Boolean.getBoolean(existsAttr);
            String v = WinRegistry.getRegistryValue(scope, key, value, "DEFAULT_VALUE");
            if (v.equals("DEFAULT_VALUE") && !exists) {
                processRegistryElements(el);
            } else if (!v.equals("DEFAULT_VALUE") && exists) {
                processRegistryElements(el);
            }
        } else if (notAttr != null) {
            boolean not = Boolean.getBoolean(notAttr == null ? "false" : notAttr);
            String v = WinRegistry.getRegistryValue(scope, key, value, "");

            if (equalsAttr.equals(v) && !not) {
                processRegistryElements(el);
            } else if (!equalsAttr.equals(v) && not) {
                processRegistryElements(el);
            }
        }

    }
}

From source file:com.dtolabs.rundeck.ExpandRunServer.java

@SuppressWarnings("static-access")
public ExpandRunServer() {

    Option baseDir = OptionBuilder.withLongOpt("basedir").hasArg().withDescription("The basedir")
            .withArgName("PATH").create('b');

    Option serverDir = OptionBuilder.withLongOpt("serverdir").hasArg()
            .withDescription("The base directory for the server").withArgName("PATH").create();

    Option binDir = OptionBuilder.withLongOpt("bindir").hasArg().withArgName("PATH")
            .withDescription("The install directory for the tools used by users.").create('x');

    Option sbinDir = OptionBuilder.withLongOpt("sbindir").hasArg().withArgName("PATH")
            .withDescription("The install directory for the tools used by administrators.").create('s');

    Option configDir = OptionBuilder.withLongOpt("configdir").hasArg().withArgName("PATH")
            .withDescription("The location of the configuration.").create('c');

    Option dataDir = OptionBuilder.withLongOpt("datadir").hasArg().withArgName("PATH")
            .withDescription("The location of Rundeck's runtime data.").create();

    Option projectDir = OptionBuilder.withLongOpt("projectdir").hasArg().withArgName("PATH")
            .withDescription("The location of Rundeck's project data.").create('p');

    Option help = OptionBuilder.withLongOpt("help").withDescription("Display this message.").create('h');

    Option debugFlag = OptionBuilder.withDescription("Show debug information").create('d');

    Option skipInstall = OptionBuilder.withLongOpt(FLAG_SKIPINSTALL)
            .withDescription("Skip the extraction of the utilities from the launcher.").create();

    Option installonly = OptionBuilder.withLongOpt(FLAG_INSTALLONLY)
            .withDescription("Perform installation only and do not start the server.").create();

    options.addOption(baseDir);/*from ww w  . j  av a2  s  .c o  m*/
    options.addOption(dataDir);
    options.addOption(serverDir);
    options.addOption(binDir);
    options.addOption(sbinDir);
    options.addOption(configDir);
    options.addOption(help);
    options.addOption(debugFlag);
    options.addOption(skipInstall);
    options.addOption(installonly);
    options.addOption(projectDir);

    debug = Boolean.getBoolean(SYS_PROP_RUNDECK_LAUNCHER_DEBUG);
    rewrite = Boolean.getBoolean(SYS_PROP_RUNDECK_LAUNCHER_REWRITE);
    useJaas = null == System.getProperty(SYS_PROP_RUNDECK_JAASLOGIN)
            || Boolean.getBoolean(SYS_PROP_RUNDECK_JAASLOGIN);
    runClassName = RUN_SERVER_CLASS;
    thisJar = thisJarFile();
    //load jar attributes
    final Attributes mainAttributes = getJarMainAttributes();
    if (null == mainAttributes) {
        throw new RuntimeException("Unable to load attributes");
    }

    versionString = mainAttributes.getValue(RUNDECK_VERSION);
    if (null != versionString) {
        DEBUG("Rundeck version: " + versionString);
    } else {
        throw new RuntimeException("Jar file attribute not found: " + RUNDECK_VERSION);
    }
    runClassName = mainAttributes.getValue(RUNDECK_START_CLASS);
    if (null == runClassName) {
        throw new RuntimeException("Jar file attribute not found: " + RUNDECK_START_CLASS);
    }
    jettyLibsString = mainAttributes.getValue(RUNDECK_JETTY_LIBS);
    if (null == jettyLibsString) {
        throw new RuntimeException("Jar file attribute not found: " + RUNDECK_JETTY_LIBS);
    }
    jettyLibPath = mainAttributes.getValue(RUNDECK_JETTY_LIB_PATH);
    if (null == jettyLibPath) {
        throw new RuntimeException("Jar file attribute not found: " + RUNDECK_JETTY_LIB_PATH);
    }
}

From source file:org.apache.jackrabbit.oak.run.SegmentUtils.java

static void compact(File directory, boolean force) throws IOException {
    FileStore store = openFileStore(directory.getAbsolutePath(), force);
    try {/*from   ww  w  .ja v a2  s .  c  om*/
        boolean persistCM = Boolean.getBoolean("tar.PersistCompactionMap");
        CompactionStrategy compactionStrategy = new CompactionStrategy(false,
                CompactionStrategy.CLONE_BINARIES_DEFAULT, CompactionStrategy.CleanupType.CLEAN_ALL, 0,
                CompactionStrategy.MEMORY_THRESHOLD_DEFAULT) {

            @Override
            public boolean compacted(Callable<Boolean> setHead) throws Exception {
                // oak-run is doing compaction single-threaded
                // hence no guarding needed - go straight ahead
                // and call setHead
                return setHead.call();
            }
        };
        compactionStrategy.setOfflineCompaction(true);
        compactionStrategy.setPersistCompactionMap(persistCM);
        store.setCompactionStrategy(compactionStrategy);
        store.compact();
    } finally {
        store.close();
    }

    System.out.println("    -> cleaning up");
    store = openFileStore(directory.getAbsolutePath(), false);
    try {
        for (File file : store.cleanup()) {
            if (!file.exists() || file.delete()) {
                System.out.println("    -> removed old file " + file.getName());
            } else {
                System.out.println("    -> failed to remove old file " + file.getName());
            }
        }

        String head;
        File journal = new File(directory, "journal.log");
        JournalReader journalReader = new JournalReader(journal);
        try {
            head = journalReader.iterator().next() + " root " + System.currentTimeMillis() + "\n";
        } finally {
            journalReader.close();
        }

        RandomAccessFile journalFile = new RandomAccessFile(journal, "rw");
        try {
            System.out.println("    -> writing new " + journal.getName() + ": " + head);
            journalFile.setLength(0);
            journalFile.writeBytes(head);
            journalFile.getChannel().force(false);
        } finally {
            journalFile.close();
        }
    } finally {
        store.close();
    }
}

From source file:executor.TesterMainGUIMode.java

public void start() throws Exception {
    // get the instance of the IClient interface
    final ITesterClient client = TesterFactory.getDefaultInstance();
    // set the listener that will receive system events

    if (StringUtils.isNotEmpty(PropertyHandler.getProperty(StrategyProperties.HISTORY_DATE_START))) {
        final SimpleDateFormat dateFormat = new SimpleDateFormat(
                PropertyHandler.getProperty(StrategyProperties.HISTORY_DATE_FORMAT));
        dateFormat.setTimeZone(/*from ww  w .j a  va2s . co m*/
                TimeZone.getTimeZone(PropertyHandler.getProperty(StrategyProperties.HISTORY_DATE_TIMEZONE)));

        Date dateFrom = dateFormat.parse(PropertyHandler.getProperty(StrategyProperties.HISTORY_DATE_START));
        Date dateTo = dateFormat.parse(PropertyHandler.getProperty(StrategyProperties.HISTORY_DATE_END));
        client.setDataInterval(DataLoadingMethod.ALL_TICKS, dateFrom.getTime(), dateTo.getTime());
    }

    final String strategyName = strategy.getClass().getName();
    client.setSystemListener(new ISystemListener() {
        @Override
        public void onStart(long processId) {
            LOGGER.info("Strategy started: " + processId);
            updateButtons();
        }

        @Override
        public void onStop(long processId) {
            LOGGER.info("Strategy stopped: " + processId);
            resetButtons();
            LOGGER.info("Strategy stopped: " + processId);
            SimpleDateFormat sdf = new SimpleDateFormat(
                    PropertyHandler.getProperty(StrategyProperties.REPORTER_CURRENT_REPORT_FORMAT));
            String propertyFolder = PropertyHandler
                    .getProperty(StrategyProperties.REPORTER_CURRENT_REPORT_OUTPUT_DIRECTORY);
            File reportFile;

            if (Boolean.getBoolean(
                    PropertyHandler.getProperty(StrategyProperties.REPORTER_CURRENT_REPORT_OVERWRITABLE))) {
                reportFile = new File(propertyFolder + strategyName + ".html");
            } else {
                reportFile = new File(
                        propertyFolder + sdf.format(GregorianCalendar.getInstance().getTime()) + ".html");
            }
            try {
                client.createReport(processId, reportFile);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
            if (client.getStartedStrategies().size() == 0) {
                // Do nothing
            }
        }

        @Override
        public void onConnect() {
            LOGGER.info("Connected");
        }

        @Override
        public void onDisconnect() {
            // tester doesn't disconnect
        }
    });

    LOGGER.info("Connecting...");
    // connect to the server using jnlp, user name and password
    // connection is needed for data downloading
    client.connect("https://www.dukascopy.com/client/demo/jclient/jforex.jnlp",
            PropertyHandler.getProperty(StrategyProperties.CLIENT_USERNAME),
            PropertyHandler.getProperty(StrategyProperties.CLIENT_PASSWORD));

    // wait for it to connect
    int i = 10; // wait max ten seconds
    while (i > 0 && !client.isConnected()) {
        Thread.sleep(1000);
        i--;
    }
    if (!client.isConnected()) {
        LOGGER.error("Failed to connect Dukascopy servers");
        System.exit(1);
    }

    // set instruments that will be used in testing
    for (String anInstrument : PropertyHandler.getProperty(StrategyProperties.CLIENT_INSTRUMENTS_USED)
            .split(",")) {
        instrumentsToAdd.add(Instrument.fromString(anInstrument));
    }

    final Set<Instrument> instruments = new HashSet<>();
    instruments.addAll(instrumentsToAdd);

    LOGGER.info("Subscribing instruments...");
    client.setSubscribedInstruments(instruments);
    // setting initial deposit
    client.setInitialDeposit(
            Instrument
                    .fromString(PropertyHandler.getProperty(StrategyProperties.CLIENT_DEPOSIT_INITIAL_CURRENCY))
                    .getSecondaryJFCurrency(),
            Double.parseDouble(PropertyHandler.getProperty(StrategyProperties.CLIENT_DEPOSIT_INITIAL_AMOUNT)));
    // load data
    LOGGER.info("Downloading data");
    Future<?> future = client.downloadData(null);
    // wait for downloading to complete
    future.get();
    // start the strategy
    LOGGER.info("Starting strategy");
    client.startStrategy(strategy, new LoadingProgressListener() {
        @Override
        public void dataLoaded(long startTime, long endTime, long currentTime, String information) {
            LOGGER.info(information);
        }

        @Override
        public void loadingFinished(boolean allDataLoaded, long startTime, long endTime, long currentTime) {
        }

        @Override
        public boolean stopJob() {
            return false;
        }
    }, this, this);
    // now it's running
}