1 16 package org.apache.cocoon.transformation.helpers; 17 18 import java.io.IOException ; 19 import java.io.Serializable ; 20 21 import org.apache.avalon.framework.logger.Logger; 22 import org.apache.excalibur.store.Store; 23 24 32 public final class StoreIncludeCacheStorageProxy 33 implements IncludeCacheStorageProxy { 34 35 private Store store; 36 37 private Logger logger; 38 39 44 public StoreIncludeCacheStorageProxy(Store store, Logger logger) { 45 this.store = store; 46 this.logger = logger; 47 } 48 49 50 private String getKey(String uri) { 51 return "DCS:" + uri; 52 } 53 54 57 public Serializable get(String uri) { 58 if (logger.isDebugEnabled()) { 59 logger.debug("StoreProxy: Getting content for " + uri); 60 } 61 62 Serializable result = (Serializable )this.store.get(this.getKey(uri)); 63 64 if (logger.isDebugEnabled()) { 65 logger.debug("StoreProxy: Result for " + uri + " : " + (result == null ? "Not in cache" : "Found")); 66 } 67 return result; 68 } 69 70 73 public void put(String uri, Serializable object) 74 throws IOException { 75 if (logger.isDebugEnabled()) { 76 logger.debug("StoreProxy: Storing content for " + uri); 77 } 78 this.store.store(this.getKey(uri), object); 79 } 80 81 84 public void remove(String uri) { 85 if (logger.isDebugEnabled()) { 86 logger.debug("StoreProxy: Removing content for " + uri); 87 } 88 this.store.remove(this.getKey(uri)); 89 } 90 } 91 | Popular Tags |