Example usage for org.apache.commons.lang BooleanUtils toBoolean

List of usage examples for org.apache.commons.lang BooleanUtils toBoolean

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toBoolean.

Prototype

public static boolean toBoolean(String str) 

Source Link

Document

Converts a String to a boolean (optimised for performance).

'true', 'on' or 'yes' (case insensitive) will return true.

Usage

From source file:org.mule.tools.apikit.output.deployer.MuleDeployPropertiesParser.java

public MuleDeployProperties parse(File muleDeployFile) {
    try {//www .  j a v  a2s.  com
        final Properties p = loadProperties(new FileInputStream(muleDeployFile));

        MuleDeployProperties deployProperties = new MuleDeployProperties();
        deployProperties.setEncoding(p.getProperty(PROPERTY_ENCODING));
        deployProperties.setConfigurationBuilder(p.getProperty(PROPERTY_CONFIG_BUILDER));
        deployProperties.setDomain(p.getProperty(PROPERTY_DOMAIN));
        deployProperties.setPackagesToScan(p.getProperty(PROPERTY_SCAN_PACKAGES));

        final String resProps = p.getProperty(PROPERTY_CONFIG_RESOURCES);

        if (!StringUtils.isBlank(resProps)) {
            String[] urls;
            urls = resProps.split(",");
            deployProperties.setConfigResources(Arrays.asList(urls));
        }

        deployProperties.setRedeploymentEnabled(
                BooleanUtils.toBoolean(p.getProperty(PROPERTY_REDEPLOYMENT_ENABLED, Boolean.TRUE.toString())));
        deployProperties.setLoaderOverride(p.getProperty(PROPERTY_LOADER_OVERRIDE));
        return deployProperties;

    } catch (IOException ioe) {
        // Return default values
        return new MuleDeployProperties();
    }
}

From source file:org.mule.transport.amqp.AbstractSslConnectivityITCase.java

@Before
public void ensureAmqpsTestsMustRun() {
    assumeTrue(BooleanUtils.toBoolean(System.getProperty("runAmqpsTests")));
}

From source file:org.mule.transport.amqp.AmqpEndpointUtil.java

public static String getOrCreateQueue(final Channel channel, final ImmutableEndpoint endpoint,
        final boolean activeDeclarationsOnly, final String exchangeName, final String routingKey)
        throws IOException {
    final String queueName = getQueueName(endpoint.getAddress());

    if (StringUtils.isBlank(queueName)) {
        // no queue name -> create a private one on the server
        final DeclareOk queueDeclareResult = channel.queueDeclare();

        final String privateQueueName = queueDeclareResult.getQueue();
        LOG.info("Declared private queue: " + privateQueueName);

        bindQueue(channel, endpoint, exchangeName, routingKey, privateQueueName);
        return privateQueueName;
    }/*from www .jav  a2  s  .  com*/

    // queue name -> either create or ensure the queue exists
    if (endpoint.getProperties().containsKey(QUEUE_DURABLE)
            || endpoint.getProperties().containsKey(QUEUE_AUTO_DELETE)
            || endpoint.getProperties().containsKey(QUEUE_EXCLUSIVE)) {
        // any of the queue declaration parameter provided -> declare the queue
        final boolean queueDurable = BooleanUtils.toBoolean((String) endpoint.getProperty(QUEUE_DURABLE));
        final boolean queueExclusive = BooleanUtils.toBoolean((String) endpoint.getProperty(QUEUE_EXCLUSIVE));
        final boolean queueAutoDelete = BooleanUtils
                .toBoolean((String) endpoint.getProperty(QUEUE_AUTO_DELETE));

        final Map<String, Object> arguments = getArguments(endpoint, QUEUE_PREFIX);

        channel.queueDeclare(queueName, queueDurable, queueExclusive, queueAutoDelete, arguments);
        LOG.info("Declared queue: " + queueName + ", durable: " + queueDurable + ", exclusive: "
                + queueExclusive + ", autoDelete: " + queueAutoDelete + ", arguments: " + arguments);

        bindQueue(channel, endpoint, exchangeName, routingKey, queueName);
    } else if (!activeDeclarationsOnly) {
        // no declaration parameter -> ensure the queue exists
        channel.queueDeclarePassive(queueName);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Validated presence of queue: " + queueName);
        }
    }

    return queueName;
}

From source file:org.mule.transport.amqp.AmqpEndpointUtil.java

public static String getOrCreateExchange(final Channel channel, final ImmutableEndpoint endpoint,
        final boolean activeDeclarationsOnly) throws IOException {
    final String endpointAddress = endpoint.getAddress();
    final String exchangeName = getExchangeName(endpointAddress, endpoint.getConnector().getProtocol());

    if (isDefaultExchange(exchangeName)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Using default exchange for endpoint: " + endpoint);
        }/* w w  w.j a  va2  s  .  c  o m*/

        return AmqpConstants.DEFAULT_EXCHANGE_ALIAS;
    }

    final String exchangeType = (String) endpoint.getProperty(EXCHANGE_TYPE);
    if (StringUtils.isNotBlank(exchangeType)) {
        // an exchange type is provided -> the exchange must be declared
        final boolean exchangeDurable = BooleanUtils.toBoolean((String) endpoint.getProperty(EXCHANGE_DURABLE));
        final boolean exchangeAutoDelete = BooleanUtils
                .toBoolean((String) endpoint.getProperty(EXCHANGE_AUTO_DELETE));

        final Map<String, Object> arguments = getArguments(endpoint, EXCHANGE_PREFIX);

        channel.exchangeDeclare(exchangeName, exchangeType, exchangeDurable, exchangeAutoDelete, arguments);

        LOG.info("Declared exchange: " + exchangeName + " of type: " + exchangeType + ", durable: "
                + exchangeDurable + ", autoDelete: " + exchangeAutoDelete + ", arguments: " + arguments);
    } else if (!activeDeclarationsOnly) {
        // no exchange type -> ensure the exchange exists
        channel.exchangeDeclarePassive(exchangeName);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Validated presence of exchange: " + exchangeName);
        }
    }

    return exchangeName;
}

From source file:org.mule.transport.amqp.harness.AbstractItSslCase.java

@Before
public void ensureAmqpsTestsMustRun() {
    assumeThat(BooleanUtils.toBoolean(System.getProperty("runAmqpsTests")), is(true));
}

From source file:org.mule.transport.amqp.internal.client.AmqpDeclarer.java

public String declareEndpoint(final Channel channel, final ImmutableEndpoint endpoint,
        final boolean activeDeclarationsOnly, final String exchangeName, final String routingKey)
        throws IOException {
    final String queueName = endpointUtil.getQueueName(endpoint.getAddress());

    // no queue name -> create a private one on the server
    if (StringUtils.isBlank(queueName)) {
        final String privateQueueName = declareTemporaryQueue(channel);
        declareBinding(channel, endpoint, exchangeName, routingKey, privateQueueName);
        return privateQueueName;
    }/*from   w ww  .  j  a va 2  s  .  c  om*/

    if (logger.isDebugEnabled()) {
        logger.debug("Declaring endpoint with URI: " + endpoint.getEndpointURI() + " with exchange: "
                + exchangeName + " rountingKey: " + routingKey + " queueName: " + queueName);
    }

    // queue name -> either create or ensure the queue exists
    if (endpoint.getProperties().containsKey(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_DURABLE)
            || endpoint.getProperties().containsKey(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_AUTO_DELETE)
            || endpoint.getProperties().containsKey(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_EXCLUSIVE)) {
        // any of the queue declaration parameter provided -> declare the queue
        final boolean queueDurable = BooleanUtils
                .toBoolean((String) endpoint.getProperty(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_DURABLE));
        final boolean queueExclusive = BooleanUtils
                .toBoolean((String) endpoint.getProperty(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_EXCLUSIVE));
        final boolean queueAutoDelete = BooleanUtils
                .toBoolean((String) endpoint.getProperty(AmqpConnector.ENDPOINT_PROPERTY_QUEUE_AUTO_DELETE));

        final Map<String, Object> arguments = endpointUtil.getArguments(endpoint,
                AmqpConnector.ENDPOINT_QUEUE_PREFIX);

        declareQueueActively(channel, queueName, queueDurable, queueExclusive, queueAutoDelete, arguments);

        declareBinding(channel, endpoint, exchangeName, routingKey, queueName);
    } else if (!activeDeclarationsOnly) {
        // no declaration parameter -> ensure the queue exists
        declareQueuePassively(channel, queueName);
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Declared endpoint with URI: " + endpoint.getEndpointURI() + " with exchange: "
                + exchangeName + " rountingKey: " + routingKey + " queueName: " + queueName);
    }

    return queueName;
}

From source file:org.mule.transport.amqp.internal.endpoint.AmqpEndpointUtil.java

public boolean isExchangeDurable(final ImmutableEndpoint endpoint) {
    return BooleanUtils
            .toBoolean((String) endpoint.getProperty(AmqpConnector.ENDPOINT_PROPERTY_EXCHANGE_DURABLE));
}

From source file:org.mule.transport.amqp.internal.endpoint.AmqpEndpointUtil.java

public boolean isExchangeAutoDelete(final ImmutableEndpoint endpoint) {
    return BooleanUtils
            .toBoolean((String) endpoint.getProperty(AmqpConnector.ENDPOINT_PROPERTY_EXCHANGE_AUTO_DELETE));
}

From source file:org.mule.transport.http.HttpClientMessageDispatcher.java

protected boolean returnException(MuleEvent event, HttpMethod httpMethod) {
    String disableCheck = event.getMessage()
            .getInvocationProperty(HttpConnector.HTTP_DISABLE_STATUS_CODE_EXCEPTION_CHECK);
    if (disableCheck == null) {
        disableCheck = event.getMessage()
                .getOutboundProperty(HttpConnector.HTTP_DISABLE_STATUS_CODE_EXCEPTION_CHECK);
    }//ww w. j a  va 2 s  . c o  m
    return httpMethod.getStatusCode() >= ERROR_STATUS_CODE_RANGE_START && !BooleanUtils.toBoolean(disableCheck);
}

From source file:org.mule.transport.jersey.JerseyMessageReceiver.java

private boolean isTrue(String string, boolean defaultValue) {
    if (string == null)
        return defaultValue;

    return BooleanUtils.toBoolean(string);
}