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

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

Introduction

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

Prototype

public String getString(String key, String defaultValue) 

Source Link

Document

Get a string associated with the given configuration key.

Usage

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)
 *///ww  w  . j  a  va 2s .  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.StringResourceLoader.java

/**
 * @see bboss.org.apache.velocity.runtime.resource.loader.ResourceLoader#init(org.apache.commons.collections.ExtendedProperties)
 *///from   w  ww.j a  v a 2s  .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);
    }/* www .  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.giraph.debugger.mock.PrefixedClasspathResourceLoader.java

@Override
public void init(ExtendedProperties configuration) {
    prefix = configuration.getString("prefix", "");
}

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   w ww.ja  v a2 s.  co  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.carrot2.workbench.velocity.BundleResourceLoader.java

/**
 * /*from   w w  w.  j  a  v a2s . c  o m*/
 */
@Override
public void init(ExtendedProperties props) {
    if (bundle != null) {
        return;
    }

    final String bundleID = props.getString(BUNDLE_ID, null);
    if (bundleID == null) {
        throw new RuntimeException("Initialize bundle key in Velocity properties: " + BUNDLE_ID);
    }

    this.bundle = locateBundle(bundleID);
}

From source file:org.kalypso.ui.editor.diagrameditor.ObservationDiagramEditor.java

@Override
public IExportableObject[] createExportableObjects(final ExtendedProperties conf) {
    return new IExportableObject[] { new ExportableChart(m_obsChart,
            conf.getString(ImageExportPage.CONF_IMAGE_FORMAT, ExportableChart.DEFAULT_FORMAT),
            conf.getInt(ImageExportPage.CONF_IMAGE_WIDTH, ExportableChart.DEFAULT_WIDTH),
            conf.getInt(ImageExportPage.CONF_IMAGE_HEIGHT, ExportableChart.DEFAULT_HEIGHT), getTitle(),
            Messages.getString("org.kalypso.ui.editor.diagrameditor.ObservationDiagramEditor.1"), null) }; //$NON-NLS-1$
}

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) };
}

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

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

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

    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);
        }
    }
}