View Javadoc
1 /* 2 * ReadCommitedCache.java 3 * 4 * $Id: ReadCommitedCache.java,v 1.6 2003/06/27 17:44:24 baliuka Exp $ 5 */ 6 7 package net.sf.voruta; 8 9 /*** 10 * 11 * @author baliuka 12 */ 13 class ReadCommitedCache extends ReadUncommitedCache{ 14 15 private ThreadLocal localCahe = new ThreadLocal(); 16 17 18 protected SoftRefMemoryCache getLocal(){ 19 20 SoftRefMemoryCache local = (SoftRefMemoryCache)localCahe.get(); 21 if(local == null){ 22 local = new SoftRefMemoryCache(); 23 localCahe.set(local); 24 } 25 return local; 26 27 } 28 29 public Object get(Object key){ 30 31 Object value = getLocal().get(key); 32 if(value == null){ 33 value = super.get(key); 34 } 35 return value; 36 } 37 38 39 public void put(Object key, Object value){ 40 41 getLocal().put(key,value); 42 43 } 44 45 public void afterCommit() { 46 47 SoftRefMemoryCache local = (SoftRefMemoryCache)localCahe.get(); 48 if(local != null){ 49 synchronized(global){ 50 global.putAll(local); 51 } 52 } 53 localCahe.set(null); 54 55 } 56 57 public void afterRollback() { 58 localCahe.set(null); 59 } 60 61 public void clear() { 62 super.clear(); 63 SoftRefMemoryCache local = (SoftRefMemoryCache)localCahe.get(); 64 if(local != null){ 65 local.clear(); 66 } 67 68 } 69 70 public void beforeBegin() { 71 72 localCahe.set(null); 73 74 } 75 76 77 }

This page was automatically generated by Maven