1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| package org.jboss.cache.pojo.interceptors.dynamic; |
9 |
| |
10 |
| import org.jboss.aop.joinpoint.Invocation; |
11 |
| import org.jboss.cache.Fqn; |
12 |
| import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException; |
13 |
| import org.jboss.cache.pojo.impl.PojoCacheImpl; |
14 |
| import org.jboss.cache.pojo.impl.PojoInstance; |
15 |
| import org.jboss.cache.pojo.util.ObjectUtil; |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| @SuppressWarnings({"CanBeFinal"}) |
24 |
| public abstract class AbstractCollectionInterceptor implements BaseInterceptor |
25 |
| { |
26 |
| Fqn fqn; |
27 |
| PojoCacheImpl cache; |
28 |
| |
29 |
| private boolean attached_ = true; |
30 |
| private PojoInstance pojoInstance_; |
31 |
| |
32 |
1748
| AbstractCollectionInterceptor(PojoCacheImpl cache, Fqn fqn)
|
33 |
| { |
34 |
1748
| this.fqn = fqn;
|
35 |
1748
| this.cache = cache;
|
36 |
| } |
37 |
| |
38 |
20149
| @SuppressWarnings({"CanBeFinal"})
|
39 |
| public Fqn getFqn() |
40 |
| { |
41 |
20149
| return fqn;
|
42 |
| } |
43 |
| |
44 |
0
| @SuppressWarnings({"CanBeFinal"})
|
45 |
| public void setFqn(Fqn fqn) |
46 |
| { |
47 |
0
| this.fqn = fqn;
|
48 |
| } |
49 |
| |
50 |
0
| @SuppressWarnings({"CanBeFinal"})
|
51 |
| public PojoInstance getAopInstance() |
52 |
| { |
53 |
0
| return pojoInstance_;
|
54 |
| } |
55 |
| |
56 |
1672
| public void setAopInstance(PojoInstance pojoInstance)
|
57 |
| { |
58 |
1672
| this.pojoInstance_ = pojoInstance;
|
59 |
| } |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
0
| public void attach(Fqn fqn, boolean copyToCache)
|
65 |
| { |
66 |
| |
67 |
0
| if (fqn != null)
|
68 |
| { |
69 |
0
| setFqn(fqn);
|
70 |
| } |
71 |
0
| attached_ = true;
|
72 |
| |
73 |
| } |
74 |
| |
75 |
1332
| public void detach(boolean removeFromCache)
|
76 |
| { |
77 |
1332
| attached_ = false;
|
78 |
| |
79 |
| } |
80 |
| |
81 |
5116
| public boolean isAttached()
|
82 |
| { |
83 |
5116
| return attached_;
|
84 |
| } |
85 |
| |
86 |
| |
87 |
5116
| public void verifyAttached(Object target)
|
88 |
| { |
89 |
| |
90 |
5116
| if (! isAttached())
|
91 |
0
| return;
|
92 |
| |
93 |
5116
| if (cache.getCache().get(fqn, PojoInstance.KEY) != null)
|
94 |
5115
| return;
|
95 |
| |
96 |
1
| String identity = ObjectUtil.identityString(target);
|
97 |
1
| throw new PojoCacheAlreadyDetachedException(identity + " has possibly been detached remotely. Internal id: " + fqn);
|
98 |
| } |
99 |
| |
100 |
| abstract void setInMemoryCopy(Object obj); |
101 |
| abstract Object getInMemoryCopy(); |
102 |
| abstract void setCacheCopy(Object obj); |
103 |
| abstract Object getCacheCopy(); |
104 |
| abstract void setCurrentCopy(Object obj); |
105 |
| public abstract Object getCurrentCopy(); |
106 |
| } |