Example usage for org.apache.commons.collections.map AbstractReferenceMap SOFT

List of usage examples for org.apache.commons.collections.map AbstractReferenceMap SOFT

Introduction

In this page you can find the example usage for org.apache.commons.collections.map AbstractReferenceMap SOFT.

Prototype

int SOFT

To view the source code for org.apache.commons.collections.map AbstractReferenceMap SOFT.

Click Source Link

Document

Constant indicating that soft references should be used

Usage

From source file:com.google.gwt.dev.cfg.ModuleDefLoader.java

@SuppressWarnings("unchecked")
private static Map<String, ModuleDef> getModulesCache() {
    ClassLoader keyClassLoader = Thread.currentThread().getContextClassLoader();
    Map<String, ModuleDef> cache = loadedModulesCaches.get(keyClassLoader);
    if (cache == null) {
        cache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
        loadedModulesCaches.put(keyClassLoader, cache);
    }// w  w  w .  j  ava2  s  .c om
    return cache;
}

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

@SuppressWarnings("unchecked")
public Map<Object, Persistent> createObjectMap() {
    String strategy = runtimeProperties.get(Constants.SERVER_OBJECT_RETAIN_STRATEGY_PROPERTY);

    if (strategy == null || WEAK_RETAIN_STRATEGY.equals(strategy)) {
        return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
    } else if (SOFT_RETAIN_STRATEGY.equals(strategy)) {
        return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
    } else if (HARD_RETAIN_STRATEGY.equals(strategy)) {
        return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.HARD);
    } else {//from w w w  . j  ava2 s.c  o m
        throw new CayenneRuntimeException("Unsupported retain strategy %s", strategy);
    }
}

From source file:org.apache.cocoon.components.modules.input.XMLFileModule.java

/**
 * Static (cocoon.xconf) configuration./* w w  w  .  j av a  2s . co  m*/
 * Configuration is expected to be of the form:
 * &lt;...&gt;
 *   &lt;reloadable&gt;true|<b>false</b>&lt;/reloadable&gt;
 *   &lt;cacheable&gt;<b>true</b>|false&lt;/cacheable&gt;
 *   &lt;file src="<i>src1</i>" reloadable="true|<b>false</b>" cacheable="<b>true</b>|false"/&gt;
 *   &lt;file src="<i>src2</i>" reloadable="true|<b>false</b>" cacheable="<b>true</b>|false"/&gt;
 *   ...
 * &lt;/...&gt;
 *
 * Each &lt;file/&gt; element pre-loads an XML DOM for querying. Typically only one
 * &lt;file&gt; is specified, and its <i>src</i> is used as a default if not
 * overridden in the {@link #getContextObject(Configuration, Map)}
 *
 * @param config a <code>Configuration</code> value, as described above.
 * @exception ConfigurationException if an error occurs
 */
public void configure(Configuration config) throws ConfigurationException {
    super.configure(config);
    this.staticConfLocation = config.getLocation();
    this.reloadAll = config.getChild("reloadable").getValueAsBoolean(false);

    if (config.getChild("cachable", false) != null) {
        throw new ConfigurationException("Bzzt! Wrong spelling at " + config.getChild("cachable").getLocation()
                + ": please use 'cacheable', not 'cachable'");
    }
    this.cacheAll = config.getChild("cacheable").getValueAsBoolean(true);

    this.documents = Collections.synchronizedMap(new HashMap());
    Configuration[] files = config.getChildren("file");
    for (int i = 0; i < files.length; i++) {
        boolean reload = files[i].getAttributeAsBoolean("reloadable", this.reloadAll);
        boolean cache = files[i].getAttributeAsBoolean("cacheable", this.cacheAll);
        this.src = files[i].getAttribute("src");
        // by assigning the source uri to this.src the last one will be the default
        // OTOH caching / reload parameters can be specified in one central place
        // if multiple file tags are used.
        this.documents.put(files[i], new DocumentHelper(reload, cache, this.src, this));
    }

    // init caches
    this.cacheExpressions = config.getChild("cache-expressions").getValueAsBoolean(true);
    if (this.cacheExpressions) {
        this.expressionCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
        this.expressionValuesCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
    }
}

From source file:org.apache.myfaces.ext202patch.application.viewstate.SerializedViewCollection.java

/**
 * @return old serialized views map//w  w  w  .j av  a 2  s. c  om
 */
@SuppressWarnings("unchecked")
protected Map<Object, Object> getOldSerializedViewsMap() {
    FacesContext context = FacesContext.getCurrentInstance();
    if (_oldSerializedViews == null && context != null) {
        String cacheMode = getCacheOldViewsInSessionMode(context);
        if (ServerSideStateCacheImpl.CACHE_OLD_VIEWS_IN_SESSION_MODE_WEAK.equals(cacheMode)) {
            _oldSerializedViews = new ReferenceMap(AbstractReferenceMap.WEAK, AbstractReferenceMap.WEAK, true);
        } else if (ServerSideStateCacheImpl.CACHE_OLD_VIEWS_IN_SESSION_MODE_SOFT_WEAK.equals(cacheMode)) {
            _oldSerializedViews = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.WEAK, true);
        } else if (ServerSideStateCacheImpl.CACHE_OLD_VIEWS_IN_SESSION_MODE_SOFT.equals(cacheMode)) {
            _oldSerializedViews = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT, true);
        } else if (ServerSideStateCacheImpl.CACHE_OLD_VIEWS_IN_SESSION_MODE_HARD_SOFT.equals(cacheMode)) {
            _oldSerializedViews = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
        }
    }

    return _oldSerializedViews;
}

From source file:org.nuxeo.ecm.core.storage.sql.SelectionContext.java

@SuppressWarnings("unchecked")
public SelectionContext(SelectionType selType, Serializable criterion, RowMapper mapper,
        PersistenceContext context) {//from www .ja v a 2s .c om
    this.selType = selType;
    this.criterion = criterion;
    this.mapper = mapper;
    this.context = context;
    softMap = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
    hardMap = new HashMap<Serializable, Selection>();
    modifiedInTransaction = new HashSet<Serializable>();
    modifiedInTransactionCount = registry.counter(MetricRegistry.name("nuxeo", "repositories",
            context.session.repository.getName(), "caches", "selections", "modified"));
    cacheHitCount = registry.counter(MetricRegistry.name("nuxeo", "repositories",
            context.session.repository.getName(), "caches", "selections", "hit"));
    cacheGetTimer = registry.timer(MetricRegistry.name("nuxeo", "repositories",
            context.session.repository.getName(), "caches", "selections", "get"));
}

From source file:org.nuxeo.ecm.core.storage.sql.SoftRefCachingRowMapper.java

@SuppressWarnings("unchecked")
public SoftRefCachingRowMapper() {
    cache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT);
    localInvalidations = new Invalidations();
    cacheQueue = new InvalidationsQueue("mapper-" + this);
    forRemoteClient = false;//from www.j  a  va2  s .  c  om
}

From source file:org.seasar.mayaa.impl.engine.PageImpl.java

protected Map getBeginRenderListeners() {
    synchronized (this) {
        if (_beginRenderListeners == null) {
            _beginRenderListeners = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.WEAK,
                    true);// w ww  .  j a v  a 2s. c  o m
        }
    }
    return _beginRenderListeners;
}

From source file:uk.ac.diamond.scisoft.analysis.rcp.views.HistogramView.java

/**
 * Default constructor/* w  w  w  . j av  a2  s . c o m*/
 */

public HistogramView() {
    histogramFunc = new Histogram(histogramSize);
    xAxis = new AxisValues();
    cachedMaxMin = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
}