1 package org.apache.ojb.broker.cache; 2 3 17 18 import org.apache.ojb.broker.Identity; 19 20 30 public abstract class AbstractMetaCache implements ObjectCache 31 { 32 public static final int METHOD_CACHE = 1; 33 public static final int METHOD_LOOKUP = 2; 34 public static final int METHOD_REMOVE = 3; 35 36 47 public abstract ObjectCache getCache(Identity oid, Object obj, int callingMethod); 48 49 55 public void cache(Identity oid, Object obj) 56 { 57 if (oid != null && obj != null) 58 { 59 ObjectCache cache = getCache(oid, obj, METHOD_CACHE); 60 if (cache != null) 61 { 62 cache.cache(oid, obj); 63 } 64 } 65 } 66 67 72 public boolean cacheIfNew(Identity oid, Object obj) 73 { 74 cache(oid, obj); 75 return true; 76 } 77 78 84 public Object lookup(Identity oid) 85 { 86 Object ret = null; 87 if (oid != null) 88 { 89 ObjectCache cache = getCache(oid, null, METHOD_LOOKUP); 90 if (cache != null) 91 { 92 ret = cache.lookup(oid); 93 } 94 } 95 return ret; 96 } 97 98 103 public void remove(Identity oid) 104 { 105 if (oid == null) return; 106 107 ObjectCache cache = getCache(oid, null, METHOD_REMOVE); 108 if (cache != null) 109 { 110 cache.remove(oid); 111 } 112 } 113 } 114 | Popular Tags |