Example usage for org.apache.commons.collections ExtendedProperties getLong

List of usage examples for org.apache.commons.collections ExtendedProperties getLong

Introduction

In this page you can find the example usage for org.apache.commons.collections ExtendedProperties getLong.

Prototype

public Long getLong(String key, Long defaultValue) 

Source Link

Document

Get a long associated with the given configuration key.

Usage

From source file:bboss.org.apache.velocity.runtime.resource.loader.ResourceLoader.java

/**
 * This initialization is used by all resource
 * loaders and must be called to set up common
 * properties shared by all resource loaders
 * @param rs//from   ww  w .j a v  a 2s .c  om
 * @param configuration
 */
public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
    this.rsvc = rs;
    this.log = rsvc.getLog();

    /*
     *  these two properties are not required for all loaders.
     *  For example, for ClasspathLoader, what would cache mean?
     *  so adding default values which I think are the safest
     *
     *  don't cache, and modCheckInterval irrelevant...
     */

    try {
        isCachingOn = configuration.getBoolean("cache", false);
    } catch (Exception e) {
        isCachingOn = false;
        String msg = "Exception parsing cache setting: " + configuration.getString("cache");
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }
    try {
        modificationCheckInterval = configuration.getLong("modificationCheckInterval", 0);
    } catch (Exception e) {
        modificationCheckInterval = 0;
        String msg = "Exception parsing modificationCheckInterval setting: "
                + configuration.getString("modificationCheckInterval");
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }

    /*
     * this is a must!
     */
    className = ResourceCacheImpl.class.getName();
    try {
        className = configuration.getString("class", className);
    } catch (Exception e) {
        String msg = "Exception retrieving resource cache class name";
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:org.apache.cayenne.access.DataRowStore.java

protected void initWithProperties(Map properties) {
    ExtendedProperties propertiesWrapper = new ExtendedProperties();

    if (properties != null) {
        propertiesWrapper.putAll(properties);
    }/*www  .  j  av  a  2  s.  c  om*/

    long snapshotsExpiration = propertiesWrapper.getLong(SNAPSHOT_EXPIRATION_PROPERTY,
            SNAPSHOT_EXPIRATION_DEFAULT);

    maxSize = propertiesWrapper.getInt(SNAPSHOT_CACHE_SIZE_PROPERTY, SNAPSHOT_CACHE_SIZE_DEFAULT);

    boolean notifyRemote = propertiesWrapper.getBoolean(REMOTE_NOTIFICATION_PROPERTY,
            REMOTE_NOTIFICATION_DEFAULT);

    String eventBridgeFactory = propertiesWrapper.getString(EVENT_BRIDGE_FACTORY_PROPERTY,
            EVENT_BRIDGE_FACTORY_DEFAULT);

    if (logger.isDebugEnabled()) {
        logger.debug("DataRowStore property " + SNAPSHOT_EXPIRATION_PROPERTY + " = " + snapshotsExpiration);
        logger.debug("DataRowStore property " + SNAPSHOT_CACHE_SIZE_PROPERTY + " = " + maxSize);
        logger.debug("DataRowStore property " + REMOTE_NOTIFICATION_PROPERTY + " = " + notifyRemote);
        logger.debug("DataRowStore property " + EVENT_BRIDGE_FACTORY_PROPERTY + " = " + eventBridgeFactory);
    }

    // init ivars from properties
    this.notifyingRemoteListeners = notifyRemote;

    this.snapshots = new ConcurrentLinkedHashMap.Builder<ObjectId, DataRow>().maximumWeightedCapacity(maxSize)
            .build();

    // init event bridge only if we are notifying remote listeners
    if (notifyingRemoteListeners) {
        try {
            EventBridgeFactory factory = (EventBridgeFactory) Class.forName(eventBridgeFactory).newInstance();

            Collection<EventSubject> subjects = Collections.singleton(getSnapshotEventSubject());
            String externalSubject = EventBridge.convertToExternalSubject(getSnapshotEventSubject());
            this.remoteNotificationsHandler = factory.createEventBridge(subjects, externalSubject, properties);
        } catch (Exception ex) {
            throw new CayenneRuntimeException("Error initializing DataRowStore.", ex);
        }

        startListeners();
    }
}

From source file:org.apache.flex.forks.velocity.runtime.resource.loader.ResourceLoader.java

/**
 * This initialization is used by all resource
 * loaders and must be called to set up common
 * properties shared by all resource loaders
 *///from www . j a va 2s . co m
public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
    this.rsvc = rs;

    /*
     *  these two properties are not required for all loaders.
     *  For example, for ClasspathLoader, what would cache mean? 
     *  so adding default values which I think are the safest
     *
     *  don't cache, and modCheckInterval irrelevant...
     */

    isCachingOn = configuration.getBoolean("cache", false);
    modificationCheckInterval = configuration.getLong("modificationCheckInterval", 0);

    /*
     * this is a must!
     */

    className = configuration.getString("class");
}

From source file:org.apache.velocity.runtime.resource.loader.ResourceLoader.java

/**
 * This initialization is used by all resource
 * loaders and must be called to set up common
 * properties shared by all resource loaders
 * @param rs//from w w  w  .ja  v a  2s .com
 * @param configuration
 */
public void commonInit(RuntimeServices rs, ExtendedProperties configuration) {
    this.rsvc = rs;

    /*
     *  these two properties are not required for all loaders.
     *  For example, for ClasspathLoader, what would cache mean?
     *  so adding default values which I think are the safest
     *
     *  don't cache, and modCheckInterval irrelevant...
     */

    try {
        isCachingOn = configuration.getBoolean("cache", false);
    } catch (Exception e) {
        isCachingOn = false;
        String msg = "Exception parsing cache setting: " + configuration.getString("cache");
        Logger.error(this, msg, e);
        throw new VelocityException(msg, e);
    }
    try {
        modificationCheckInterval = configuration.getLong("modificationCheckInterval", 0);
    } catch (Exception e) {
        modificationCheckInterval = 0;
        String msg = "Exception parsing modificationCheckInterval setting: "
                + configuration.getString("modificationCheckInterval");
        Logger.error(this, msg, e);
        throw new VelocityException(msg, e);
    }

    /*
     * this is a must!
     */
    className = ResourceCacheImpl.class.getName();
    try {
        className = configuration.getString("class", className);
    } catch (Exception e) {
        String msg = "Exception retrieving resource cache class name";
        Logger.error(this, msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:org.objectstyle.cayenne.access.DataRowStore.java

protected void initWithProperties(Map properties) {
    ExtendedProperties propertiesWrapper = new ExtendedProperties();

    if (properties != null) {
        propertiesWrapper.putAll(properties);
    }/*from   w  w  w  .j a  v  a2  s .co  m*/

    long snapshotsExpiration = propertiesWrapper.getLong(SNAPSHOT_EXPIRATION_PROPERTY,
            SNAPSHOT_EXPIRATION_DEFAULT);

    int snapshotsCacheSize = propertiesWrapper.getInt(SNAPSHOT_CACHE_SIZE_PROPERTY,
            SNAPSHOT_CACHE_SIZE_DEFAULT);

    boolean notifyRemote = propertiesWrapper.getBoolean(REMOTE_NOTIFICATION_PROPERTY,
            REMOTE_NOTIFICATION_DEFAULT);

    String eventBridgeFactory = propertiesWrapper.getString(EVENT_BRIDGE_FACTORY_PROPERTY,
            EVENT_BRIDGE_FACTORY_DEFAULT);

    if (logObj.isDebugEnabled()) {
        logObj.debug("DataRowStore property " + SNAPSHOT_EXPIRATION_PROPERTY + " = " + snapshotsExpiration);
        logObj.debug("DataRowStore property " + SNAPSHOT_CACHE_SIZE_PROPERTY + " = " + snapshotsCacheSize);
        logObj.debug("DataRowStore property " + REMOTE_NOTIFICATION_PROPERTY + " = " + notifyRemote);
        logObj.debug("DataRowStore property " + EVENT_BRIDGE_FACTORY_PROPERTY + " = " + eventBridgeFactory);
    }

    // init ivars from properties
    this.notifyingRemoteListeners = notifyRemote;

    // TODO: ENTRY EXPIRATION is not supported by commons LRU Map
    this.snapshots = new LRUMap(snapshotsCacheSize);

    // TODO: cache size should really be a sum of all result lists sizes...
    // so we must track it outside the LRUMap...
    this.snapshotLists = new LRUMap(snapshotsCacheSize);

    // init event bridge only if we are notifying remote listeners
    if (notifyingRemoteListeners) {
        try {
            EventBridgeFactory factory = (EventBridgeFactory) Class.forName(eventBridgeFactory).newInstance();
            this.remoteNotificationsHandler = factory.createEventBridge(getSnapshotEventSubject(), properties);

            // listen to EventBridge
            EventManager.getDefaultManager().addListener(this, "processRemoteEvent", SnapshotEvent.class,
                    getSnapshotEventSubject(), remoteNotificationsHandler);

            // start EventBridge - it will listen to all event sources for this
            // subject
            remoteNotificationsHandler.startup(EventManager.getDefaultManager(),
                    EventBridge.RECEIVE_LOCAL_EXTERNAL);
        } catch (Exception ex) {
            throw new CayenneRuntimeException("Error initializing DataRowStore.", ex);
        }
    }
}