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