Example usage for org.apache.commons.configuration Configuration getLong

List of usage examples for org.apache.commons.configuration Configuration getLong

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getLong.

Prototype

Long getLong(String key, Long defaultValue);

Source Link

Document

Get a Long associated with the given configuration key.

Usage

From source file:org.apache.qpid.server.store.derby.DerbyMessageStore.java

private void commonConfiguration(String name, Configuration storeConfiguration)
        throws ClassNotFoundException, SQLException {
    initialiseDriver();/*from w  w  w  .ja  va  2s .  com*/

    //Update to pick up QPID_WORK and use that as the default location not just derbyDB

    final String databasePath = storeConfiguration.getString(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY,
            System.getProperty("QPID_WORK") + File.separator + "derbyDB");

    if (!MEMORY_STORE_LOCATION.equals(databasePath)) {
        File environmentPath = new File(databasePath);
        if (!environmentPath.exists()) {
            if (!environmentPath.mkdirs()) {
                throw new IllegalArgumentException(
                        "Environment path " + environmentPath + " could not be read or created. "
                                + "Ensure the path is correct and that the permissions are correct.");
            }
        }
    }

    _storeLocation = databasePath;

    _persistentSizeHighThreshold = storeConfiguration.getLong(MessageStoreConstants.OVERFULL_SIZE_PROPERTY,
            -1l);
    _persistentSizeLowThreshold = storeConfiguration.getLong(MessageStoreConstants.UNDERFULL_SIZE_PROPERTY,
            _persistentSizeHighThreshold);
    if (_persistentSizeLowThreshold > _persistentSizeHighThreshold || _persistentSizeLowThreshold < 0l) {
        _persistentSizeLowThreshold = _persistentSizeHighThreshold;
    }

    createOrOpenDatabase(name, databasePath);

    Connection conn = newAutoCommitConnection();
    ;
    try {
        _totalStoreSize = getSizeOnDisk(conn);
    } finally {
        conn.close();
    }
}

From source file:org.apache.qpid.server.store.QuotaMessageStore.java

@Override
public void configureConfigStore(String name, ConfigurationRecoveryHandler recoveryHandler,
        Configuration config) throws Exception {
    _persistentSizeHighThreshold = config.getLong(MessageStoreConstants.OVERFULL_SIZE_PROPERTY, Long.MAX_VALUE);
    _persistentSizeLowThreshold = config.getLong(MessageStoreConstants.UNDERFULL_SIZE_PROPERTY,
            _persistentSizeHighThreshold);
    if (_persistentSizeLowThreshold > _persistentSizeHighThreshold || _persistentSizeLowThreshold < 0l) {
        _persistentSizeLowThreshold = _persistentSizeHighThreshold;
    }/* w  w  w . jav  a 2s.  c  o m*/
    _stateManager.attainState(State.INITIALISING);
}

From source file:org.apache.torque.dsfactory.JndiDataSourceFactory.java

/**
 * Initializes JNDI./*from  w  w w  .jav a 2  s .c o  m*/
 *
 * @param configuration where to read the settings from
 * @throws TorqueException if a property set fails
 */
private void initJNDI(Configuration configuration) throws TorqueException {
    log.debug("Starting initJNDI");

    Configuration c = configuration.subset(JNDI_KEY);
    if (c == null || c.isEmpty()) {
        throw new TorqueException(
                "JndiDataSourceFactory requires a jndi " + "path property to lookup the DataSource in JNDI.");
    }

    try {
        Hashtable<String, Object> env = new Hashtable<String, Object>();
        for (Iterator<?> i = c.getKeys(); i.hasNext();) {
            String key = (String) i.next();
            if (key.equals(PATH_KEY)) {
                path = c.getString(key);
                if (log.isDebugEnabled()) {
                    log.debug("JNDI path: " + path);
                }
            } else if (key.equals(TIME_BETWEEN_LOOKUPS_KEY)) {
                ttl = c.getLong(key, ttl);
                if (log.isDebugEnabled()) {
                    log.debug("Time between context lookups: " + ttl);
                }
            } else {
                String value = c.getString(key);
                env.put(key, value);
                if (log.isDebugEnabled()) {
                    log.debug("Set jndi property: " + key + "=" + value);
                }
            }
        }

        ctx = new InitialContext(env);
        log.debug("Created new InitialContext");
        debugCtx(ctx);
    } catch (Exception e) {
        log.error("", e);
        throw new TorqueException(e);
    }
}

From source file:org.cesecore.config.OcspConfiguration.java

/**
 * The default number of milliseconds a response is valid, or -1 to disable. See RFC5019.
 *///w  w w.j a  v a 2 s .c o  m
public static long getExpiredArchiveCutoff() {
    Configuration config = ConfigurationHolder.instance();

    if (StringUtils.equals(config.getString(EXPIREDCERT_RETENTIONPERIOD), "-1")) {
        return -1;
    }

    long value = 31536000;
    try {
        value = config.getLong(EXPIREDCERT_RETENTIONPERIOD, value) * 1000;
    } catch (ConversionException e) {
        log.warn(
                "\"ocsp.expiredcert.retentionperiod\" is not a decimal integer. Using default value: " + value);
    }

    return value;
}

From source file:org.cesecore.config.OcspConfiguration.java

/**
 * The default number of milliseconds a response is valid, or 0 to disable. See RFC5019.
 *//*from   www  . j  ava2s  .  c om*/
public static long getUntilNextUpdate(int certProfileId) {
    long value = 0;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".untilNextUpdate";
    if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = UNTIL_NEXT_UPDATE;
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        log.warn("\"ocsp.untilNextUpdate\" is not a decimal integer. Using default value: " + value);
    }
    return value;
}

From source file:org.cesecore.config.OcspConfiguration.java

/**
 * The default number of milliseconds a response of a revoked certificate is valid, or 0 to disable. See RFC5019.
 *//*from  w  ww  . j  ava 2  s.  co m*/
public static long getRevokedUntilNextUpdate(int certProfileId) {
    long value = 0;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".revoked.untilNextUpdate";
    if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = REVOKED_UNTIL_NEXT_UPDATE;
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        log.warn("\"ocsp.revoked.untilNextUpdate\" is not a decimal integer. Using default value: " + value);
    }
    return value;
}

From source file:org.cesecore.config.OcspConfiguration.java

/**
 * The default number of milliseconds a HTTP-response should be cached. See RFC5019.
 *//*from w  w w . j  av a  2 s. com*/
public static long getMaxAge(int certProfileId) {
    long value = 30;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".maxAge";
    if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = MAX_AGE;
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        // Convert default value to milliseconds
        value = value * 1000;
        log.warn("\"ocsp.maxAge\" is not a decimal integer. Using default value: " + value);
    }
    return value;
}

From source file:org.cesecore.config.OcspConfiguration.java

/**
 * The default number of milliseconds a HTTP-response for a revoked certificater should be cached. See RFC5019.
 *///from www.j a v  a  2  s  . com
public static long getRevokedMaxAge(int certProfileId) {
    long value = 30;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".revoked.maxAge";
    if ((certProfileId == CertificateProfileConstants.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = REVOKED_MAX_AGE;
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        // Convert default value to milliseconds
        value = value * 1000;
        log.warn("\"ocsp.revoked.maxAge\" is not a decimal integer. Using default value: " + value);
    }
    return value;
}

From source file:org.ejbca.config.OcspConfiguration.java

/** 
 * The default number of milliseconds a response is valid, or 0 to disable. See RFC5019.
 *//*ww  w . ja  va 2s .  c  o  m*/
public static long getUntilNextUpdate(int certProfileId) {
    long value = 0;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".untilNextUpdate";
    if ((certProfileId == SecConst.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = "ocsp.untilNextUpdate";
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        log.warn("\"ocsp.untilNextUpdate\" is not a decimal number. Using default value: " + value);
    }
    return value;
}

From source file:org.ejbca.config.OcspConfiguration.java

/**
 * The default number of milliseconds a HTTP-response should be cached. See RFC5019.
 *///from   ww w  .j a  v  a 2s . co  m
public static long getMaxAge(int certProfileId) {
    long value = 30;
    Configuration config = ConfigurationHolder.instance();
    String key = "ocsp." + certProfileId + ".maxAge";
    if ((certProfileId == SecConst.CERTPROFILE_NO_PROFILE) || (!config.containsKey(key))) {
        key = "ocsp.maxAge";
    }
    try {
        value = (config.getLong(key, value) * 1000);
    } catch (ConversionException e) {
        // Convert default value to milliseconds
        value = value * 1000;
        log.warn("\"ocsp.maxAge\" is not a decimal number. Using default value: " + value);
    }
    return value;
}