Coverage Report - org.kuali.rice.kns.util.KualiLRUMap
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiLRUMap
0%
0/11
N/A
1.333
 
 1  
 /*
 2  
  * Copyright 2006-2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kns.util;
 17  
 
 18  
 import org.apache.commons.collections.map.LRUMap;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.kns.service.impl.SessionDocumentServiceImpl;
 21  
 
 22  
 /**
 23  
  * Override LRUMap removeEntity method
 24  
  * 
 25  
  * 
 26  
  */
 27  
 public class KualiLRUMap extends LRUMap {
 28  
 
 29  
         /** Serialization version */
 30  
         private static final long serialVersionUID = 1L;
 31  
 
 32  
         public KualiLRUMap() {
 33  0
                 super();
 34  0
         }
 35  
 
 36  
         public KualiLRUMap(int maxSize) {
 37  0
                 super(maxSize);
 38  0
         }
 39  
 
 40  
         protected void removeEntry(HashEntry entry, int hashIndex, HashEntry previous) {
 41  
 
 42  
                 // It is for session document cache enhancement.
 43  
                 // To control the size of cache. When the LRUMap reach the maxsize.
 44  
                 // It will remove session document entries from the in-memory user
 45  
                 // session objects.
 46  
                 try {
 47  0
                         SessionDocumentServiceImpl.CachedObject cachedObject 
 48  
                                         = (SessionDocumentServiceImpl.CachedObject)this.entryValue(entry);
 49  0
                         cachedObject.getUserSession().removeObject(cachedObject.getFormKey());
 50  0
                 } catch (Exception ex) {
 51  0
                         Logger.getLogger(getClass()).warn( "Problem purging old entry from the user session when removing from the map: ", ex);
 52  0
                 }
 53  
 
 54  0
                 super.removeEntry(entry, hashIndex, previous);
 55  0
         }
 56  
 
 57  
 }