|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.engine.state; |
|
16 |
| |
|
17 |
| import java.util.HashMap; |
|
18 |
| import java.util.Iterator; |
|
19 |
| import java.util.Map; |
|
20 |
| |
|
21 |
| import org.apache.hivemind.PoolManageable; |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| public class ApplicationStateManagerImpl implements ApplicationStateManager, PoolManageable |
|
30 |
| { |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| private Map _stateObjects = new HashMap(); |
|
37 |
| |
|
38 |
| private StateObjectManagerRegistry _registry; |
|
39 |
| |
|
40 |
369
| public void activateService()
|
|
41 |
| { |
|
42 |
| } |
|
43 |
| |
|
44 |
372
| public void passivateService()
|
|
45 |
| { |
|
46 |
372
| _stateObjects.clear();
|
|
47 |
| } |
|
48 |
| |
|
49 |
6
| public boolean exists(String objectName)
|
|
50 |
| { |
|
51 |
6
| return _stateObjects.containsKey(objectName) || _registry.get(objectName).exists();
|
|
52 |
| } |
|
53 |
| |
|
54 |
24
| public Object get(String objectName)
|
|
55 |
| { |
|
56 |
24
| Object result = _stateObjects.get(objectName);
|
|
57 |
| |
|
58 |
24
| if (result == null)
|
|
59 |
| { |
|
60 |
21
| result = _registry.get(objectName).get();
|
|
61 |
| |
|
62 |
18
| _stateObjects.put(objectName, result);
|
|
63 |
| } |
|
64 |
| |
|
65 |
21
| return result;
|
|
66 |
| } |
|
67 |
| |
|
68 |
0
| public void store(String objectName, Object stateObject)
|
|
69 |
| { |
|
70 |
0
| _registry.get(objectName).store(stateObject);
|
|
71 |
| |
|
72 |
0
| _stateObjects.put(objectName, stateObject);
|
|
73 |
| } |
|
74 |
| |
|
75 |
372
| public void flush()
|
|
76 |
| { |
|
77 |
372
| Iterator i = _stateObjects.entrySet().iterator();
|
|
78 |
372
| while (i.hasNext())
|
|
79 |
| { |
|
80 |
9
| Map.Entry e = (Map.Entry) i.next();
|
|
81 |
| |
|
82 |
9
| String objectName = (String) e.getKey();
|
|
83 |
9
| Object stateObject = e.getValue();
|
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
9
| _registry.get(objectName).store(stateObject);
|
|
88 |
| } |
|
89 |
| } |
|
90 |
| |
|
91 |
129
| public void setRegistry(StateObjectManagerRegistry registry)
|
|
92 |
| { |
|
93 |
129
| _registry = registry;
|
|
94 |
| } |
|
95 |
| } |