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

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

Introduction

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

Prototype

public LRUMap(Map map) 

Source Link

Document

Constructor copying elements from another map.

Usage

From source file:org.opencms.util.CmsCollectionsGenericWrapper.java

/**
 * Provides a wrapper to create a {@link LRUMap} with the given size that avoids warnings with Java 1.5 generic code.<p> 
 * //from   w  w  w.  j  ava2s  . c  o  m
 * @param <K> the type of keys maintained by the returned map
 * @param <V> the type of mapped values
 * @param size the initial size of the created Map
 * 
 * @return a {@link LRUMap} with the given size of the required generic type
 */
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> createLRUMap(int size) {

    return new LRUMap(size);
}

From source file:org.openddr.simpleapi.oddr.identificator.CachedBrowserIdentificator.java

public CachedBrowserIdentificator(Builder[] builders, Map<String, Browser> browserCapabilities,
        Integer maxCacheSize, Integer maxNotFoundUASize) {
    super(builders, browserCapabilities);
    browserCache = new LRUMap(maxCacheSize);
    notFoundUA = new LRUMap(maxNotFoundUASize);
}

From source file:org.openddr.simpleapi.oddr.identificator.CachedDeviceIdentificator.java

public CachedDeviceIdentificator(DeviceBuilder[] builders, Map<String, Device> devices, Integer maxCacheSize,
        Integer maxNotFoundUASize) {
    super(builders, devices);
    deviceCache = new LRUMap(maxCacheSize);
    notFoundUA = new LRUMap(maxNotFoundUASize);
}

From source file:org.openddr.simpleapi.oddr.identificator.CachedOSIdentificator.java

public CachedOSIdentificator(Builder[] builders, Map<String, OperatingSystem> operatingSystemCapabilities,
        Integer maxCacheSize, Integer maxNotFoundUASize) {
    super(builders, operatingSystemCapabilities);
    osCache = new LRUMap(maxCacheSize);
    notFoundUA = new LRUMap(maxNotFoundUASize);
}

From source file:org.openhab.binding.fibaro.internal.InMemoryCache.java

public InMemoryCache(long crunchifyTimeToLive, final long crunchifyTimerInterval, int maxItems) {
    this.timeToLive = crunchifyTimeToLive * 1000;

    crunchifyCacheMap = new LRUMap(maxItems);

    if (timeToLive > 0 && crunchifyTimerInterval > 0) {

        Thread t = new Thread(new Runnable() {
            @Override//www .j  a  v  a 2  s  . c  o  m
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(crunchifyTimerInterval * 1000);
                    } catch (InterruptedException ex) {
                    }
                    cleanup();
                }
            }
        });

        t.setDaemon(true);
        t.start();
    }
}

From source file:org.oscarehr.provider.model.PreventionManager.java

public PreventionManager() {
    demoPrevs = new LRUMap(MAXITEMS);
    mShell = new HashMap<String, LRUMap>(1);
    mShell.put(PREVS, demoPrevs);/* w  w w . j  a  va  2s  . co m*/
    mShell = Collections.synchronizedMap(mShell);
    pf = PreventionDS.getInstance();
}

From source file:org.parosproxy.paros.network.SSLConnector.java

public SSLConnector(boolean relaxedTrust) {
    this.relaxedTrust = relaxedTrust;
    if (clientSSLSockFactory == null) {
        serverSslSocketsDecorator = new ServerSslSocketsDecorator();
        clientSslSocketsDecorator = new ClientSslSocketsDecorator();

        clientSSLSockFactory = getClientSocketFactory(SSL);
        misconfiguredHosts = new LRUMap(10);
    }/*from   w w  w .  j  a v a  2 s .c o  m*/
    // ZAP: removed ServerSocketFaktory
    if (sslContextManager == null) {
        sslContextManager = new SSLContextManager();
    }

}

From source file:org.xchain.framework.scanner.ScannerLifecycle.java

private void putCached(ClassLoader classLoader, RootUrlLocator locator, ScanNode scanNode) {
    Map<RootUrlLocator, ScanNode> locatorScanNodeMap = this.cache.get(classLoader);
    if (locatorScanNodeMap == null) {
        locatorScanNodeMap = Collections.synchronizedMap(new LRUMap(20));
        this.cache.put(classLoader, locatorScanNodeMap);
    }//from   w  w w  .j av a2s .c  o m
    locatorScanNodeMap.put(locator, scanNode);
}

From source file:org.xenei.jena.security.SecuredItemImpl.java

public static void incrementUse() {
    final Integer i = SecuredItemImpl.COUNT.get();
    if (i == null) {
        SecuredItemImpl.CACHE.set(new LRUMap(Math.max(SecuredItemImpl.MAX_CACHE, 100)));
        SecuredItemImpl.COUNT.set(Integer.valueOf(1));
    } else {/*from w  ww  .j  av  a  2s. com*/
        SecuredItemImpl.COUNT.set(Integer.valueOf(i + 1));
    }
}

From source file:org.zaproxy.zap.extension.ascanrulesAlpha.GitIndexEntryCache.java

/**
 * puts the Git Index and Git Index Entry in a map
 *
 * @param gitIndexUri/*w  ww .j a  va 2  s  .  c om*/
 * @param gitIndexEntryUri
 */
@SuppressWarnings("unchecked")
public synchronized void putIndexEntry(URI gitIndexUri, URI gitIndexEntryUri, String gitSHA1) {
    Map<URI, String> indexEntryMap;
    if (gitIndexMap.containsKey(gitIndexUri)) {
        indexEntryMap = gitIndexMap.get(gitIndexUri);
    } else {
        indexEntryMap = Collections.synchronizedMap(new LRUMap(1000)); // max: 1000 Git index entries (LRU)
    }
    indexEntryMap.put(gitIndexEntryUri, gitSHA1);
    gitIndexMap.put(gitIndexUri, indexEntryMap);
}