1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.util;
17
18 import java.util.Properties;
19
20 import org.apache.log4j.Logger;
21 import org.apache.ojb.broker.Identity;
22 import org.apache.ojb.broker.PersistenceBroker;
23 import org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl;
24
25 public class KualiObjectCachePerBrokerImpl extends ObjectCachePerBrokerImpl {
26 private static final Logger LOG = Logger.getLogger(KualiObjectCachePerBrokerImpl.class);
27
28
29 private final String brokerId;
30
31 public KualiObjectCachePerBrokerImpl(PersistenceBroker broker, Properties prop) {
32 super(broker, prop);
33 brokerId = broker.getClass().getName() + "@" + broker.hashCode();
34
35 LOG.debug("created objectCache for broker " + brokerId);
36 }
37
38
39
40
41 public void clear() {
42 super.clear();
43
44 LOG.debug("cleared objectCache for broker " + brokerId);
45 }
46
47
48
49
50 public void cache(Identity oid, Object obj) {
51 super.cache(oid, obj);
52
53 boolean cached = (super.lookup(oid) != null);
54 LOG.debug((cached ? "cached oid " : "unable to cache oid ") + oid + " in objectCache for broker " + brokerId);
55 }
56
57
58
59
60 public boolean cacheIfNew(Identity oid, Object obj) {
61 boolean cachedIfNew = super.cacheIfNew(oid, obj);
62
63 boolean cached = (super.lookup(oid) != null);
64 LOG.debug((cached ? "cached new oid " : "unable to cache new oid ") + oid + " in objectCache for broker " + brokerId);
65
66 return cachedIfNew;
67 }
68
69
70
71
72 public Object lookup(Identity oid) {
73 Object o = super.lookup(oid);
74
75 LOG.debug((o != null ? "found oid " : "cannot find oid ") + oid + " in objectCache for broker " + brokerId);
76
77 return o;
78 }
79 }