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.hivemind.util.Defense; |
19 |
|
import org.apache.tapestry.services.ComponentRenderWorker; |
20 |
|
import org.apache.tapestry.spec.IComponentSpecification; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
81 |
public class InjectRenderWorker implements EnhancementWorker |
30 |
|
{ |
31 |
|
|
32 |
|
public static final String PROPERTY_NAME = "renderWorker"; |
33 |
|
|
34 |
|
private ErrorLog _errorLog; |
35 |
|
|
36 |
|
private ComponentRenderWorker _renderWorker; |
37 |
|
|
38 |
|
public void performEnhancement(EnhancementOperation op, IComponentSpecification spec) |
39 |
|
{ |
40 |
|
try |
41 |
|
{ |
42 |
87 |
injectRenderWorker(op, spec); |
43 |
|
} |
44 |
0 |
catch (Exception ex) |
45 |
|
{ |
46 |
0 |
_errorLog.error(EnhanceMessages.errorAddingProperty(PROPERTY_NAME, op.getBaseClass(), ex), |
47 |
|
spec.getLocation(), ex); |
48 |
87 |
} |
49 |
87 |
} |
50 |
|
|
51 |
|
public void injectRenderWorker(EnhancementOperation op, IComponentSpecification spec) |
52 |
|
{ |
53 |
87 |
Defense.notNull(op, "op"); |
54 |
87 |
Defense.notNull(spec, "spec"); |
55 |
|
|
56 |
87 |
op.claimReadonlyProperty(PROPERTY_NAME); |
57 |
|
|
58 |
88 |
String fieldName = op.addInjectedField("_$" + PROPERTY_NAME, ComponentRenderWorker.class, _renderWorker); |
59 |
|
|
60 |
87 |
EnhanceUtils.createSimpleAccessor(op, fieldName, |
61 |
|
PROPERTY_NAME, ComponentRenderWorker.class, |
62 |
|
spec.getLocation()); |
63 |
87 |
} |
64 |
|
|
65 |
|
public void setErrorLog(ErrorLog errorLog) |
66 |
|
{ |
67 |
0 |
_errorLog = errorLog; |
68 |
0 |
} |
69 |
|
|
70 |
|
public void setRenderWorker(ComponentRenderWorker worker) |
71 |
|
{ |
72 |
81 |
_renderWorker = worker; |
73 |
81 |
} |
74 |
|
} |