1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.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 | 0 | 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 | 0 | super(broker, prop); |
33 | 0 | brokerId = broker.getClass().getName() + "@" + broker.hashCode(); |
34 | |
|
35 | 0 | LOG.debug("created objectCache for broker " + brokerId); |
36 | 0 | } |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public void clear() { |
42 | 0 | super.clear(); |
43 | |
|
44 | 0 | LOG.debug("cleared objectCache for broker " + brokerId); |
45 | 0 | } |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public void cache(Identity oid, Object obj) { |
51 | 0 | super.cache(oid, obj); |
52 | |
|
53 | 0 | boolean cached = (super.lookup(oid) != null); |
54 | 0 | LOG.debug((cached ? "cached oid " : "unable to cache oid ") + oid + " in objectCache for broker " + brokerId); |
55 | 0 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public boolean cacheIfNew(Identity oid, Object obj) { |
61 | 0 | boolean cachedIfNew = super.cacheIfNew(oid, obj); |
62 | |
|
63 | 0 | boolean cached = (super.lookup(oid) != null); |
64 | 0 | LOG.debug((cached ? "cached new oid " : "unable to cache new oid ") + oid + " in objectCache for broker " + brokerId); |
65 | |
|
66 | 0 | return cachedIfNew; |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public Object lookup(Identity oid) { |
73 | 0 | Object o = super.lookup(oid); |
74 | |
|
75 | 0 | LOG.debug((o != null ? "found oid " : "cannot find oid ") + oid + " in objectCache for broker " + brokerId); |
76 | |
|
77 | 0 | return o; |
78 | |
} |
79 | |
} |