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

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

Introduction

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

Prototype

public LRUMap(int i) 

Source Link

Document

Create a new LRUMap with a maximum capacity of i.

Usage

From source file:org.seasar.struts.portlet.SAStrutsPortlet.java

protected ProcessActionConfig getProcessActionConfig(PortletRequest request, Integer accessId) {
    PortletSession portletSession = request.getPortletSession();
    String currentPortletMode = request.getPortletMode().toString();
    String previousPortletMode = (String) portletSession.getAttribute(PREVIOUS_PORTLET_MODE);

    // set portlet mode
    portletSession.setAttribute(PREVIOUS_PORTLET_MODE, currentPortletMode);

    if (isPortletModeChange(currentPortletMode, previousPortletMode)) {
        // portlet mode was changed. clear cache.
        portletSession.setAttribute(PortletUtil.PROCESS_ACTION_CONFIG_MAP, new LRUMap(maxCacheSize));
        return null;
    }//from  w ww  .j a va2s  . com

    Map configMap = (Map) portletSession.getAttribute(PortletUtil.PROCESS_ACTION_CONFIG_MAP);
    if (configMap == null) {
        configMap = new LRUMap(maxCacheSize);
        portletSession.setAttribute(PortletUtil.PROCESS_ACTION_CONFIG_MAP, configMap);
    }
    return (ProcessActionConfig) configMap.get(accessId);
}