Example usage for org.apache.commons.collections15.map LRUMap LRUMap

List of usage examples for org.apache.commons.collections15.map LRUMap LRUMap

Introduction

In this page you can find the example usage for org.apache.commons.collections15.map LRUMap LRUMap.

Prototype

public LRUMap(Map<? extends K, ? extends V> map) 

Source Link

Document

Constructor copying elements from another map.

Usage

From source file:net.sqs2.omr.session.service.AbstractRemoteExecutorManager.java

public AbstractRemoteExecutorManager(TaskTracker<T, D> taskTracker, int maximumNumberOfConnections) {
    this.taskTracker = taskTracker;
    this.maximumNumberOfConnections = maximumNumberOfConnections;
    this.remoteTaskTrackerMap = new LRUMap<String, AbstractTaskTracker<T, D>>(this.maximumNumberOfConnections) {
        private static final long serialVersionUID = 0L;

        @Override//from w  w  w .j av  a2s.c o m
        protected boolean removeLRU(LinkEntry<String, AbstractTaskTracker<T, D>> entry) {
            // release resources held by entry
            (entry.getValue()).stop();
            return true; // actually delete entry
        }
    };

    new RemoteTaskTrackerManager<T, D>(this.remoteTaskTrackerMap);
}

From source file:net.sqs2.omr.task.broker.RemoteTaskExecutorManager.java

public RemoteTaskExecutorManager(TaskExecutorPeer manager, int maximumNumberOfConnections) {
    this.manager = manager;
    this.maximumNumberOfConnections = maximumNumberOfConnections;
    this.remoteTaskBrokerMap = new LRUMap<String, TaskBroker>(this.maximumNumberOfConnections) {
        private static final long serialVersionUID = 0L;

        protected boolean removeLRU(LinkEntry<String, TaskBroker> entry) {
            // release resources held by entry
            ((TaskBroker) entry.getValue()).stop();
            return true; // actually delete entry
        }//from  w  w w .  j  a va2s .  c o m
    };
}

From source file:org.echocat.jomon.resources.ClassPathResourceFactory.java

@Nonnull
protected Map<String, ClassPathResource> getPathToResourceCacheFor(@Nonnull ClassLoader classLoader) {
    Map<String, ClassPathResource> pathToResource;
    synchronized (_classLoaderToEntriesCache) {
        pathToResource = _classLoaderToEntriesCache.get(classLoader);
        if (pathToResource == null) {
            pathToResource = new LRUMap<>(_cachedEntriesPerClassLoader);
            _classLoaderToEntriesCache.put(classLoader, pathToResource);
        }/*from  w  ww  . jav a2  s .c om*/
    }
    return pathToResource;
}

From source file:org.openanzo.cache.LRUCache.java

LRUCache(int maxSize) {
    map = new LRUMap<K, V>(maxSize) {

        private static final long serialVersionUID = -4014149744440579768L;

        @Override/*  w  ww .j av a2 s  . com*/
        protected boolean removeLRU(
                org.apache.commons.collections15.map.AbstractLinkedMap.LinkEntry<K, V> entry) {
            for (ICacheListener<K, V> listener : listeners) {
                listener.elementRemoved(entry.getKey(), entry.getValue());
            }
            return super.removeLRU(entry);
        }

    };
}