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.apache.oodt.cas.cli.CmdLineUtility.java

public CmdLineUtility() {
    parser = new StdCmdLineParser();
    constructor = new StdCmdLineConstructor();
    optionStore = new SpringCmdLineOptionStoreFactory().createStore();
    actionStore = new SpringCmdLineActionStoreFactory().createStore();
    printer = new StdCmdLinePrinter();
    presenter = new StdCmdLinePresenter();

    debugMode = Boolean.getBoolean("org.apache.oodt.cas.cli.debug");
}

From source file:org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.java

public SequenceManagerHighLowImpl(PersistenceBroker broker) {
    super(broker);
    Long start = SequenceManagerHelper.getSeqStart(getConfigurationProperties());
    sequenceStart = start != null ? start.longValue() : 1;
    grabSize = Integer.parseInt(getConfigurationProperty(PROPERTY_GRAB_SIZE, "20"));
    useGlobalSequenceIdentities = Boolean
            .getBoolean(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_ID, "false"));
    // support for deprecated properties
    long globalSequenceStart = Long.parseLong(getConfigurationProperty(PROPERTY_GLOBAL_SEQUENCE_START, "1"));
    if (useGlobalSequenceIdentities && globalSequenceStart > sequenceStart) {
        sequenceStart = globalSequenceStart;
    }//from w w w.jav a2  s  .c om
}

From source file:org.rhq.server.control.RHQControl.java

public int exec(String[] args) {
    int rValue = EXIT_CODE_OK;
    ControlCommand command = null;//w  w  w  . j  av  a2  s .  c o m
    boolean undo = false;
    AbortHook abortHook = new AbortHook();

    try {
        if (args.length == 0) {
            printUsage();
            rValue = EXIT_CODE_INVALID_ARGUMENT;
        } else {
            String commandName = findCommand(commands, args);
            command = commands.get(commandName);

            if (!isHelp(args)) {
                // don't wait for user to read the warning if this is just request for help
                logWarningIfAgentRPMIsInstalled(command);
            }

            validateInstallCommand(command, args);

            // in case the installer gets killed, prepare the shutdown hook to try the undo
            abortHook.setCommand(command);
            Runtime.getRuntime().addShutdownHook(abortHook);

            // run the command
            rValue = command.exec(getCommandLine(commandName, args));
        }
    } catch (UsageException e) {
        printUsage();
        rValue = EXIT_CODE_INVALID_ARGUMENT;
    } catch (RHQControlException e) {
        undo = true;

        Throwable rootCause = ThrowableUtil.getRootCause(e);
        // Only show the messy stack trace if we're in debug mode. Otherwise keep it cleaner for the user...
        if (log.isDebugEnabled()) {
            log.error(rootCause.getMessage(), rootCause);
        } else {
            log.error(rootCause.getMessage());
        }
        rValue = EXIT_CODE_OPERATION_FAILED;
    } catch (Throwable t) {
        undo = true;
        log.error(t);
        rValue = EXIT_CODE_OPERATION_FAILED;
    } finally {
        abortHook.setCommand(null);
        Runtime.getRuntime().removeShutdownHook(abortHook);
    }

    if (undo && command != null) {
        try {
            if (!Boolean.getBoolean("rhqctl.skip.undo")) {
                command.undo();
            } else {
                throw new Exception("Was told by user to skip clean up attempt.");
            }
        } catch (Throwable t) {
            log.warn("Failed to clean up after the failed installation attempt. "
                    + "You may have to clean up some things before attempting to install again", t);
            rValue = EXIT_CODE_OPERATION_FAILED;
        }
    }

    return rValue;
}

From source file:com.hypersocket.netty.NettyServer.java

@Override
protected void doStart() throws IOException {

    System.setProperty("hypersocket.netty.debug", "true");

    clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
            bossExecutor = Executors.newCachedThreadPool(new NettyThreadFactory()),
            workerExecutors = Executors.newCachedThreadPool(new NettyThreadFactory())));

    clientBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            pipeline.addLast("handler", new SocketForwardingWebsocketClientHandler());
            return pipeline;
        }/*from  ww w. j  a va2s  .  c o m*/
    });

    // Configure the server.
    serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool()));

    // Set up the event pipeline factory.
    serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            if (Boolean.getBoolean("hypersocket.netty.debug")) {
                pipeline.addLast("logger", new LoggingHandler(InternalLogLevel.DEBUG));
            }
            pipeline.addLast("ipFilter", ipFilterHandler);
            pipeline.addLast("channelMonitor", monitorChannelHandler);
            pipeline.addLast("switcherA",
                    new SSLSwitchingHandler(NettyServer.this, getHttpPort(), getHttpsPort()));
            return pipeline;
        }
    });

    serverBootstrap.setOption("child.receiveBufferSize", 1048576);
    serverBootstrap.setOption("child.sendBufferSize", 1048576);
    serverBootstrap.setOption("backlog", 5000);

    httpChannels = new HashSet<Channel>();
    httpsChannels = new HashSet<Channel>();

    bindInterface(getHttpPort(), httpChannels);
    bindInterface(getHttpsPort(), httpsChannels);

    if (httpChannels.size() == 0 && httpsChannels.size() == 0) {
        throw new IOException("Failed to startup any listening interfaces!");
    }
}

From source file:com.fstx.stdlib.author.taglibs.CheckAuthorizationTag.java

private boolean userIsAuthorized() {

    SessionContext sessionContext = null;

    ComponentManager container = (ComponentManager) ActionContext.getContext().getSession()
            .get("DefaultComponentManager");

    sessionContext = (SessionContext) container.getComponent(SessionContextAware.class);

    /*/*from  w w w  . ja  v a  2  s.c om*/
     * check authentication
     */
    if (sessionContext == null)
        return false;

    /*
     * check valid authentication
     */
    if (sessionContext.getUser() == null)
        return false;

    AuthenticatedUser au = sessionContext.getUser();

    //SystemRights right = SystemRights.getRight(this.getRightCode());

    //log.info("attempting to authorize user " + au.getUsername() + " for
    // right " + this.getRightCode());;
    /**
     * useful since we need to, sometimes, use more than a single right code
     * with the tag
     */
    FstxTimeSystemRights[] rights = { rightCode1, rightCode2, rightCode3, rightCode4 };

    boolean authorized = Authorizer.singleton.isAuthorizedForAny(au, rights);

    boolean ret = authorized;
    /*
     * we assume we're checking if someone is, but its also possible to
     * check if someone isn't.
     */
    if (this.getCheckValue() != null && this.getCheckValue().length() > 0) {
        boolean target = Boolean.getBoolean(this.getCheckValue());

        if (target && authorized) {
            ret = true;
        } else if (!target && !authorized) {
            ret = true;
        } else if (!target && authorized) {
            ret = false;
        } else if (target && !authorized) {
            ret = false;
        }

    }
    /*
     * Make sure the systemowner and the auth user jive
     */
    SystemOwner asystemowner = null;
    try {
        asystemowner = SystemOwnerServiceDelegate.factory.build().get(au.getUser());
    } catch (Exception e) {
        ret = false;
    }
    if (!sessionContext.getSystemOwner().getKey().equals(asystemowner.getKey())) {
        ret = false;
    }

    return ret;
}

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

/**
 * Return true if should skip tests that rely on a working network
 *///from w  ww.  j  a  v  a  2s  . c  om
public boolean isSkipNetworkTests() {
    return Boolean.getBoolean("org.lockss.test.skipNetworkTests");
}

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

/**
 * @param key the key//from ww  w . ja  v  a2s  .  co  m
 * @return the property or null if not there or property no boolean
 */
@Override
public Boolean getBoolean(String key) {
    if (System.getProperty(key) != null) {
        return Boolean.getBoolean(key);
    } else {
        try {
            return configuration.getBoolean(key);
        } catch (NoSuchElementException e) { //NOSONAR
            return null;
        }
    }
}

From source file:com.diversityarrays.dalclient.DefaultDALClient.java

public DefaultDALClient(String baseUrl) {
    String s = baseUrl;/*from ww w.j  ava2s . co  m*/
    if (!s.endsWith("/")) { //$NON-NLS-1$
        s = s + "/"; //$NON-NLS-1$
    }
    this.baseUrl = s;

    if (Boolean.getBoolean(DefaultDALClient.class.getName() + ".WANT_LOGGING")) { //$NON-NLS-1$
        try {
            Class<?> logFactoryClass = Class.forName("org.apache.commons.logging.LogFactory"); //$NON-NLS-1$
            Method getLogMethod = logFactoryClass.getDeclaredMethod("getLog", Class.class); //$NON-NLS-1$
            log = (Log) getLogMethod.invoke(null, DALClient.class);
            // log = LogFactory.getLog(DALClient.class);
        } catch (ClassNotFoundException e) {
        } catch (NoSuchMethodException e) {
        } catch (SecurityException e) {
        } catch (IllegalAccessException e) {
        } catch (IllegalArgumentException e) {
        } catch (InvocationTargetException e) {
        }
    }

    String httpFactoryClassName = System.getProperty(this.getClass().getName() + ".HTTP_FACTORY_CLASS_NAME"); //$NON-NLS-1$
    if (httpFactoryClassName == null) {
        if (System.getProperty("java.vm.name").equalsIgnoreCase("Dalvik")) { //$NON-NLS-1$ //$NON-NLS-2$
            httpFactoryClassName = "com.diversityarrays.dalclient.httpandroid.AndroidDalHttpFactory"; //$NON-NLS-1$
        } else {
            httpFactoryClassName = "com.diversityarrays.dalclient.httpimpl.DalHttpFactoryImpl"; //$NON-NLS-1$
        }
    }

    try {
        Class<?> httpFactoryClass = Class.forName(httpFactoryClassName);
        if (!DalHttpFactory.class.isAssignableFrom(httpFactoryClass)) {
            throw new RuntimeException("className '" //$NON-NLS-1$
                    + httpFactoryClassName + "' does not implement " //$NON-NLS-1$
                    + DalHttpFactory.class.getName());
        }
        dalHttpFactory = (DalHttpFactory) httpFactoryClass.newInstance();

    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }

}

From source file:uk.ac.sanger.cgp.dbcon.util.DatabaseUtils.java

/**
 * This method amalgamates the other boolean methods in this class to see
 * if it should implement the system property oracle.jdbc.V8Compatible for
 * JDBC Oracle drivers.//from   w  w  w. jav a  2s .  c o m
 * @throws DbConException If it is not possible to determine whether the fix is required,
 *                        i.e. if the driver version is > 10.
 */
public static boolean setOraclePropertyForBugFix(Connection conn) throws SQLException {

    // See if compatibility hasn't already been set, and that it's oracle first.
    if (!Boolean.getBoolean("oracle.jdbc.V8Compatible") && isOracle(conn)
            && isFixRequiredForOracleVersion(conn)) {
        System.setProperty("oracle.jdbc.V8Compatible", "true");
        return true;
    }

    return false;
}

From source file:org.sonar.plugins.php.phpunit.sensor.PhpUnitSensorTest.java

private void init() {
    project = mock(Project.class);
    configuration = mock(Configuration.class);

    sensor = new PhpUnitSensor();
    when(configuration.getString(PhpUnitConfiguration.REPORT_FILE_NAME_PROPERTY_KEY,
            PhpUnitConfiguration.DEFAULT_REPORT_FILE_NAME)).thenReturn("punit.summary.xml");
    when(configuration.getString(PhpUnitConfiguration.REPORT_FILE_RELATIVE_PATH_PROPERTY_KEY,
            PhpUnitConfiguration.DEFAULT_REPORT_FILE_PATH)).thenReturn("/log");
    when(configuration.getString(PhpUnitConfiguration.COVERAGE_REPORT_FILE_PROPERTY_KEY,
            PhpUnitConfiguration.DEFAULT_COVERAGE_REPORT_FILE)).thenReturn("phpunit.coverage.xml");
    when(configuration.getBoolean(PhpUnitConfiguration.SHOULD_RUN_PROPERTY_KEY,
            Boolean.getBoolean(PhpUnitConfiguration.DEFAULT_SHOULD_RUN))).thenReturn(true);
    when(project.getConfiguration()).thenReturn(configuration);
    MavenProject mavenProject = mock(MavenProject.class);
    ProjectFileSystem fs = mock(ProjectFileSystem.class);
    when(project.getFileSystem()).thenReturn(fs);
    when(fs.getBuildDir()).thenReturn(new File(PhpUnitConfiguration.DEFAULT_REPORT_FILE_PATH));
    when(project.getPom()).thenReturn(mavenProject);
    when(project.getFileSystem()).thenReturn(fs);
    when(fs.getSourceDirs()).thenReturn(Arrays.asList(new File("C:\\projets\\PHP\\Monkey\\sources\\main")));
    when(fs.getTestDirs()).thenReturn(Arrays.asList(new File("C:\\projets\\PHP\\Monkey\\sources\\test")));
}