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

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

Introduction

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

Prototype

public Boolean getBoolean(String key, Boolean defaultValue) 

Source Link

Document

Get a boolean 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 .  jav a 2 s .  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:edu.internet2.middleware.shibboleth.common.util.StringResourceLoader.java

/**
 * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *///from   w w w. ja  va  2  s  .c o  m
public void init(final ExtendedProperties configuration) {
    log.trace("StringResourceLoader : initialization starting.");

    // get the repository configuration info
    String repoClass = configuration.getString(REPOSITORY_CLASS, REPOSITORY_CLASS_DEFAULT);
    String repoName = configuration.getString(REPOSITORY_NAME, REPOSITORY_NAME_DEFAULT);
    boolean isStatic = configuration.getBoolean(REPOSITORY_STATIC, REPOSITORY_STATIC_DEFAULT);
    String encoding = configuration.getString(REPOSITORY_ENCODING);

    // look for an existing repository of that name and isStatic setting
    if (isStatic) {
        this.repository = getRepository(repoName);
        if (repository != null && log.isDebugEnabled()) {
            log.debug("Loaded repository '" + repoName + "' from static repo store");
        }
    } else {
        this.repository = (StringResourceRepository) rsvc.getApplicationAttribute(repoName);
        if (repository != null && log.isDebugEnabled()) {
            log.debug("Loaded repository '" + repoName + "' from application attributes");
        }
    }

    if (this.repository == null) {
        // since there's no repository under the repo name, create a new one
        this.repository = createRepository(repoClass, encoding);

        // and store it according to the isStatic setting
        if (isStatic) {
            setRepository(repoName, this.repository);
        } else {
            rsvc.setApplicationAttribute(repoName, this.repository);
        }
    } else {
        // ok, we already have a repo
        // warn them if they are trying to change the class of the repository
        if (!this.repository.getClass().getName().equals(repoClass)) {
            log.warn("Cannot change class of string repository '" + repoName + "' from "
                    + this.repository.getClass().getName() + " to " + repoClass);
        }

        // allow them to change the default encoding of the repo
        if (encoding != null && !this.repository.getEncoding().equals(encoding)) {
            if (log.isInfoEnabled()) {
                log.info("Changing the default encoding of string repository '" + repoName + "' from "
                        + this.repository.getEncoding() + " to " + encoding);
            }
            this.repository.setEncoding(encoding);
        }
    }

    log.trace("StringResourceLoader : initialization complete.");
}

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

/**
 * @see bboss.org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *///from w  w w . ja va  2 s . co  m
public void init(ExtendedProperties configuration) {
    if (log.isTraceEnabled()) {
        log.trace("FileResourceLoader : initialization starting.");
    }

    paths.addAll(configuration.getVector("path"));

    // unicode files may have a BOM marker at the start, but Java
    // has problems recognizing the UTF-8 bom. Enabling unicode will
    // recognize all unicode boms.
    unicode = configuration.getBoolean("unicode", false);

    if (log.isDebugEnabled()) {
        log.debug("Do unicode file recognition:  " + unicode);
    }

    if (log.isDebugEnabled()) {
        // trim spaces from all paths
        StringUtils.trimStrings(paths);

        // this section lets tell people what paths we will be using
        int sz = paths.size();
        for (int i = 0; i < sz; i++) {
            log.debug("FileResourceLoader : adding path '" + (String) paths.get(i) + "'");
        }
        log.trace("FileResourceLoader : initialization complete.");
    }
}

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

/**
 * @see bboss.org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *//*w  ww  . ja  v a  2  s. co m*/
public void init(final ExtendedProperties configuration) {
    log.trace("StringResourceLoader : initialization starting.");

    // get the repository configuration info
    String repoClass = configuration.getString(REPOSITORY_CLASS, REPOSITORY_CLASS_DEFAULT);
    String repoName = configuration.getString(REPOSITORY_NAME, REPOSITORY_NAME_DEFAULT);
    boolean isStatic = configuration.getBoolean(REPOSITORY_STATIC, REPOSITORY_STATIC_DEFAULT);
    String encoding = configuration.getString(REPOSITORY_ENCODING);

    // look for an existing repository of that name and isStatic setting
    if (isStatic) {
        this.repository = getRepository(repoName);
        if (repository != null && log.isDebugEnabled()) {
            log.debug("Loaded repository '" + repoName + "' from static repo store");
        }
    } else {
        this.repository = (StringResourceRepository) rsvc.getApplicationAttribute(repoName);
        if (repository != null && log.isDebugEnabled()) {
            log.debug("Loaded repository '" + repoName + "' from application attributes");
        }
    }

    if (this.repository == null) {
        // since there's no repository under the repo name, create a new one
        this.repository = createRepository(repoClass, encoding);

        // and store it according to the isStatic setting
        if (isStatic) {
            setRepository(repoName, this.repository);
        } else {
            rsvc.setApplicationAttribute(repoName, this.repository);
        }
    } else {
        // ok, we already have a repo
        // warn them if they are trying to change the class of the repository
        if (!this.repository.getClass().getName().equals(repoClass)) {
            log.debug("Cannot change class of string repository '" + repoName + "' from "
                    + this.repository.getClass().getName() + " to " + repoClass
                    + ". The change will be ignored.");
        }

        // allow them to change the default encoding of the repo
        if (encoding != null && !this.repository.getEncoding().equals(encoding)) {
            if (log.isDebugEnabled()) {
                log.debug("Changing the default encoding of string repository '" + repoName + "' from "
                        + this.repository.getEncoding() + " to " + encoding);
            }
            this.repository.setEncoding(encoding);
        }
    }

    log.trace("StringResourceLoader : initialization complete.");
}

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

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

    if (properties != null) {
        propertiesWrapper.putAll(properties);
    }//from w ww . j  a v  a  2s.c  o m

    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
 *//* ww  w.  j a va2  s .c  o 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.FileResourceLoader.java

/**
 * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *///from  w  ww  . ja va  2 s .  c  o m
public void init(ExtendedProperties configuration) {
    if (Logger.isDebugEnabled(this.getClass())) {
        Logger.debug(this, "FileResourceLoader : initialization starting.");
    }

    paths.addAll(configuration.getVector("path"));

    // unicode files may have a BOM marker at the start, but Java
    // has problems recognizing the UTF-8 bom. Enabling unicode will
    // recognize all unicode boms.
    unicode = configuration.getBoolean("unicode", false);

    if (Logger.isDebugEnabled(this.getClass())) {
        Logger.debug(this, "Do unicode file recognition:  " + unicode);
    }

    if (Logger.isDebugEnabled(this.getClass())) {
        // trim spaces from all paths
        StringUtils.trimStrings(paths);

        // this section lets tell people what paths we will be using
        int sz = paths.size();
        for (int i = 0; i < sz; i++) {
            Logger.debug(this, "FileResourceLoader : adding path '" + (String) paths.get(i) + "'");
        }
        Logger.debug(this, "FileResourceLoader : initialization complete.");
    }
}

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 . j a v a  2 s.  c  o m*/
 * @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.apache.velocity.runtime.resource.loader.StringResourceLoader.java

/**
 * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *///from ww  w. ja va 2  s.  c o  m
public void init(final ExtendedProperties configuration) {
    Logger.debug(this, "StringResourceLoader : initialization starting.");

    // get the repository configuration info
    String repoClass = configuration.getString(REPOSITORY_CLASS, REPOSITORY_CLASS_DEFAULT);
    String repoName = configuration.getString(REPOSITORY_NAME, REPOSITORY_NAME_DEFAULT);
    boolean isStatic = configuration.getBoolean(REPOSITORY_STATIC, REPOSITORY_STATIC_DEFAULT);
    String encoding = configuration.getString(REPOSITORY_ENCODING);

    // look for an existing repository of that name and isStatic setting
    if (isStatic) {
        this.repository = getRepository(repoName);
        if (repository != null && Logger.isDebugEnabled(this.getClass())) {
            Logger.debug(this, "Loaded repository '" + repoName + "' from static repo store");
        }
    } else {
        this.repository = (StringResourceRepository) rsvc.getApplicationAttribute(repoName);
        if (repository != null && Logger.isDebugEnabled(this.getClass())) {
            Logger.debug(this, "Loaded repository '" + repoName + "' from application attributes");
        }
    }

    if (this.repository == null) {
        // since there's no repository under the repo name, create a new one
        this.repository = createRepository(repoClass, encoding);

        // and store it according to the isStatic setting
        if (isStatic) {
            setRepository(repoName, this.repository);
        } else {
            rsvc.setApplicationAttribute(repoName, this.repository);
        }
    } else {
        // ok, we already have a repo
        // warn them if they are trying to change the class of the repository
        if (!this.repository.getClass().getName().equals(repoClass)) {
            Logger.debug(this,
                    "Cannot change class of string repository '" + repoName + "' from "
                            + this.repository.getClass().getName() + " to " + repoClass
                            + ". The change will be ignored.");
        }

        // allow them to change the default encoding of the repo
        if (encoding != null && !this.repository.getEncoding().equals(encoding)) {
            if (Logger.isDebugEnabled(this.getClass())) {
                Logger.debug(this, "Changing the default encoding of string repository '" + repoName + "' from "
                        + this.repository.getEncoding() + " to " + encoding);
            }
            this.repository.setEncoding(encoding);
        }
    }

    Logger.debug(this, "StringResourceLoader : initialization complete.");
}

From source file:org.kalypso.ui.editor.mapeditor.MapExportableObjectFactory.java

@Override
public IExportableObject[] createExportableObjects(final ExtendedProperties conf) {
    final String preferredDocumentName = m_mapPanel.getMapModell().getName().getValue();
    final int width = conf.getInt(ImagePropertiesWizardPage.CONFIG_IMAGE_WIDTH, m_mapPanel.getWidth());
    final int height = conf.getInt(ImagePropertiesWizardPage.CONFIG_IMAGE_HEIGHT, m_mapPanel.getHeight());
    final Insets insets = (Insets) conf.getProperty(ImagePropertiesWizardPage.CONFIG_INSETS);
    final boolean border = conf.getBoolean(ImagePropertiesWizardPage.CONFIG_HAS_BORDER, false);
    final int borderWidth = border ? 1 : 0;
    final String format = conf.getString(ImagePropertiesWizardPage.CONFIG_IMAGE_FORMAT, "PNG"); //$NON-NLS-1$

    return new IExportableObject[] { new MapExportableObject(m_mapPanel, preferredDocumentName, width, height,
            insets, borderWidth, format) };
}