1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.loader; |
8 |
| |
9 |
| import org.jboss.cache.CacheImpl; |
10 |
| import org.jboss.cache.Fqn; |
11 |
| import org.jboss.cache.NodeSPI; |
12 |
| import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig; |
13 |
| |
14 |
| import java.io.ObjectInputStream; |
15 |
| import java.io.ObjectOutputStream; |
16 |
| import java.util.HashMap; |
17 |
| import java.util.Map; |
18 |
| import java.util.Set; |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| public class LocalDelegatingCacheLoader extends DelegatingCacheLoader |
37 |
| { |
38 |
| |
39 |
| IndividualCacheLoaderConfig config; |
40 |
| CacheImpl delegate = null; |
41 |
| |
42 |
106
| public LocalDelegatingCacheLoader()
|
43 |
| { |
44 |
| } |
45 |
| |
46 |
106
| public LocalDelegatingCacheLoader(CacheImpl delegate)
|
47 |
| { |
48 |
106
| this.delegate = delegate;
|
49 |
| } |
50 |
| |
51 |
106
| public void setConfig(IndividualCacheLoaderConfig config)
|
52 |
| { |
53 |
106
| this.config = config;
|
54 |
| } |
55 |
| |
56 |
106
| public IndividualCacheLoaderConfig getConfig()
|
57 |
| { |
58 |
106
| return config;
|
59 |
| } |
60 |
| |
61 |
109
| protected Set delegateGetChildrenNames(Fqn fqn) throws Exception
|
62 |
| { |
63 |
109
| return delegate.getChildrenNames(fqn);
|
64 |
| } |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
549
| protected Map delegateGet(Fqn name) throws Exception
|
72 |
| { |
73 |
549
| NodeSPI n = (NodeSPI) delegate.get(name);
|
74 |
129
| if (n == null) return null;
|
75 |
| |
76 |
420
| Map m = n.getDataDirect();
|
77 |
0
| if (m == null) m = new HashMap(0);
|
78 |
420
| return m;
|
79 |
| } |
80 |
| |
81 |
0
| protected void setDelegateCache(CacheImpl delegate)
|
82 |
| { |
83 |
0
| this.delegate = delegate;
|
84 |
| } |
85 |
| |
86 |
355
| protected boolean delegateExists(Fqn name) throws Exception
|
87 |
| { |
88 |
355
| return delegate.exists(name);
|
89 |
| } |
90 |
| |
91 |
160
| protected Object delegatePut(Fqn name, Object key, Object value) throws Exception
|
92 |
| { |
93 |
160
| return delegate.put(name, key, value);
|
94 |
| } |
95 |
| |
96 |
164
| protected void delegatePut(Fqn name, Map attributes) throws Exception
|
97 |
| { |
98 |
164
| delegate.put(name, attributes);
|
99 |
| } |
100 |
| |
101 |
46
| protected Object delegateRemove(Fqn name, Object key) throws Exception
|
102 |
| { |
103 |
46
| return delegate.remove(name, key);
|
104 |
| } |
105 |
| |
106 |
303
| protected void delegateRemove(Fqn name) throws Exception
|
107 |
| { |
108 |
303
| delegate.remove(name);
|
109 |
| } |
110 |
| |
111 |
10
| protected void delegateRemoveData(Fqn name) throws Exception
|
112 |
| { |
113 |
10
| delegate.removeData(name);
|
114 |
| } |
115 |
| |
116 |
6
| protected void delegateLoadEntireState(ObjectOutputStream os) throws Exception
|
117 |
| { |
118 |
6
| try
|
119 |
| { |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
6
| delegate.getStateTransferManager().getState(os, Fqn.ROOT, delegate.getConfiguration().getStateRetrievalTimeout(), true, false);
|
130 |
| } |
131 |
| catch (Exception e) |
132 |
| { |
133 |
0
| throw e;
|
134 |
| } |
135 |
| catch (Throwable t) |
136 |
| { |
137 |
0
| throw new RuntimeException("Caught exception getting state from delegate", t);
|
138 |
| } |
139 |
| } |
140 |
| |
141 |
0
| protected void delegateLoadState(Fqn subtree, ObjectOutputStream os) throws Exception
|
142 |
| { |
143 |
0
| throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
|
144 |
| } |
145 |
| |
146 |
0
| protected void delegateStoreEntireState(ObjectInputStream is) throws Exception
|
147 |
| { |
148 |
0
| delegate.getStateTransferManager().setState(is, Fqn.ROOT);
|
149 |
| |
150 |
| } |
151 |
| |
152 |
0
| protected void delegateStoreState(Fqn subtree, ObjectInputStream is) throws Exception
|
153 |
| { |
154 |
0
| throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
|
155 |
| } |
156 |
| |
157 |
| } |