1 package org.apache.turbine.util; 2 3 18 19 import org.apache.commons.collections.SequencedHashMap; 20 21 29 public class BufferCache 30 extends SequencedHashMap 31 { 32 35 private static final int DEFAULT_MAX_SIZE = 35; 36 37 41 private int maxSize; 42 43 46 public BufferCache() 47 { 48 this(DEFAULT_MAX_SIZE); 49 } 50 51 56 public BufferCache(int maxSize) 57 { 58 super(maxSize); 59 this.maxSize = maxSize; 60 } 61 62 71 public synchronized Object put(Object key, Object value) 72 { 73 int size = size(); 74 if (size > 0 && size + 1 >= maxSize) 75 { 76 remove(0); 79 } 80 return super.put(key, value); 81 } 82 83 90 public synchronized Object get(Object key) 91 { 92 return super.get(key); 93 } 94 } 95 | Popular Tags |