|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.enhance; |
|
16 |
| |
|
17 |
| import java.util.Iterator; |
|
18 |
| import java.util.Map; |
|
19 |
| |
|
20 |
| import org.apache.hivemind.ErrorLog; |
|
21 |
| import org.apache.tapestry.spec.IComponentSpecification; |
|
22 |
| import org.apache.tapestry.spec.InjectSpecification; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| public class DispatchToInjectWorker implements EnhancementWorker |
|
32 |
| { |
|
33 |
| private ErrorLog _errorLog; |
|
34 |
| |
|
35 |
| private Map _injectWorkers; |
|
36 |
| |
|
37 |
1176
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec)
|
|
38 |
| { |
|
39 |
1176
| Iterator i = spec.getInjectSpecifications().iterator();
|
|
40 |
| |
|
41 |
1176
| while (i.hasNext())
|
|
42 |
| { |
|
43 |
1170
| InjectSpecification is = (InjectSpecification) i.next();
|
|
44 |
| |
|
45 |
1170
| invokeWorker(op, is);
|
|
46 |
| } |
|
47 |
| } |
|
48 |
| |
|
49 |
1170
| private void invokeWorker(EnhancementOperation op, InjectSpecification spec)
|
|
50 |
| { |
|
51 |
1170
| try
|
|
52 |
| { |
|
53 |
1170
| InjectEnhancementWorker worker = (InjectEnhancementWorker) _injectWorkers.get(spec
|
|
54 |
| .getType()); |
|
55 |
| |
|
56 |
1170
| if (worker == null)
|
|
57 |
| { |
|
58 |
3
| _errorLog.error(EnhanceMessages.unknownInjectType(spec.getProperty(), spec
|
|
59 |
| .getType()), spec.getLocation(), null); |
|
60 |
3
| return;
|
|
61 |
| } |
|
62 |
| |
|
63 |
1167
| worker.performEnhancement(op, spec);
|
|
64 |
| |
|
65 |
| } |
|
66 |
| catch (Exception ex) |
|
67 |
| { |
|
68 |
3
| _errorLog.error(EnhanceMessages.errorAddingProperty(spec.getProperty(), op
|
|
69 |
| .getBaseClass(), ex), spec.getLocation(), ex); |
|
70 |
| } |
|
71 |
| } |
|
72 |
| |
|
73 |
123
| public void setErrorLog(ErrorLog errorLog)
|
|
74 |
| { |
|
75 |
123
| _errorLog = errorLog;
|
|
76 |
| } |
|
77 |
| |
|
78 |
126
| public void setInjectWorkers(Map injectWorkers)
|
|
79 |
| { |
|
80 |
126
| _injectWorkers = injectWorkers;
|
|
81 |
| } |
|
82 |
| } |