|
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.ApplicationRuntimeException; |
|
22 |
| import org.apache.hivemind.ErrorLog; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public class SOMRegistryImpl implements StateObjectManagerRegistry |
|
29 |
| { |
|
30 |
| private ErrorLog _errorLog; |
|
31 |
| |
|
32 |
| private Map _factoryContributions; |
|
33 |
| |
|
34 |
| private Map _applicationContributions; |
|
35 |
| |
|
36 |
| private Map _persistenceManagers; |
|
37 |
| |
|
38 |
| private Map _objectManagers = new HashMap(); |
|
39 |
| |
|
40 |
12
| public void initializeService()
|
|
41 |
| { |
|
42 |
12
| Map contributions = new HashMap();
|
|
43 |
12
| contributions.putAll(_factoryContributions);
|
|
44 |
| |
|
45 |
12
| contributions.putAll(_applicationContributions);
|
|
46 |
| |
|
47 |
12
| Iterator i = contributions.values().iterator();
|
|
48 |
12
| while (i.hasNext())
|
|
49 |
| { |
|
50 |
18
| StateObjectContribution c = (StateObjectContribution) i.next();
|
|
51 |
| |
|
52 |
18
| String objectName = c.getName();
|
|
53 |
18
| String scope = c.getScope();
|
|
54 |
| |
|
55 |
18
| StateObjectPersistenceManager pm = (StateObjectPersistenceManager) _persistenceManagers
|
|
56 |
| .get(scope); |
|
57 |
| |
|
58 |
18
| if (pm == null)
|
|
59 |
| { |
|
60 |
3
| _errorLog.error(
|
|
61 |
| StateMessages.unknownScope(objectName, scope), |
|
62 |
| c.getLocation(), |
|
63 |
| null); |
|
64 |
3
| continue;
|
|
65 |
| } |
|
66 |
| |
|
67 |
15
| StateObjectManager manager = new StateObjectManagerImpl(objectName, c.getFactory(), pm);
|
|
68 |
| |
|
69 |
15
| _objectManagers.put(objectName, manager);
|
|
70 |
| |
|
71 |
| } |
|
72 |
| } |
|
73 |
| |
|
74 |
21
| public StateObjectManager get(String objectName)
|
|
75 |
| { |
|
76 |
21
| StateObjectManager manager = (StateObjectManager) _objectManagers.get(objectName);
|
|
77 |
| |
|
78 |
21
| if (manager == null)
|
|
79 |
3
| throw new ApplicationRuntimeException(StateMessages.unknownStateObjectName(objectName));
|
|
80 |
| |
|
81 |
18
| return manager;
|
|
82 |
| } |
|
83 |
| |
|
84 |
12
| public void setApplicationContributions(Map applicationContributions)
|
|
85 |
| { |
|
86 |
12
| _applicationContributions = applicationContributions;
|
|
87 |
| } |
|
88 |
| |
|
89 |
9
| public void setErrorLog(ErrorLog errorLog)
|
|
90 |
| { |
|
91 |
9
| _errorLog = errorLog;
|
|
92 |
| } |
|
93 |
| |
|
94 |
12
| public void setFactoryContributions(Map factoryContributions)
|
|
95 |
| { |
|
96 |
12
| _factoryContributions = factoryContributions;
|
|
97 |
| } |
|
98 |
| |
|
99 |
12
| public void setPersistenceManagers(Map persistenceManagers)
|
|
100 |
| { |
|
101 |
12
| _persistenceManagers = persistenceManagers;
|
|
102 |
| } |
|
103 |
| } |