1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
package org.apache.tapestry.annotations; |
15 |
|
|
16 |
|
import java.util.Collection; |
17 |
|
import java.util.Iterator; |
18 |
|
|
19 |
|
import org.apache.hivemind.ApplicationRuntimeException; |
20 |
|
import org.apache.hivemind.HiveMind; |
21 |
|
import org.apache.tapestry.enhance.EnhancementOperation; |
22 |
|
import org.apache.tapestry.enhance.EnhancementWorker; |
23 |
|
import org.apache.tapestry.spec.IComponentSpecification; |
24 |
|
import org.apache.tapestry.spec.IContainedComponent; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
3 |
public class ComponentHousekeepingWorker implements EnhancementWorker |
36 |
|
{ |
37 |
|
public void performEnhancement( EnhancementOperation op, IComponentSpecification spec ) |
38 |
|
{ |
39 |
3 |
for ( Iterator i = spec.getComponentIds().iterator(); i.hasNext(); ) |
40 |
|
{ |
41 |
3 |
String id = ( String ) i.next(); |
42 |
3 |
IContainedComponent cc = spec.getComponent(id); |
43 |
3 |
String copyOf = cc.getCopyOf(); |
44 |
3 |
Collection bindingNames = cc.getBindingNames(); |
45 |
|
|
46 |
3 |
if (HiveMind.isNonBlank(copyOf) && bindingNames.size() == 0) |
47 |
|
{ |
48 |
2 |
IContainedComponent source = spec.getComponent(copyOf); |
49 |
2 |
if (source == null) |
50 |
1 |
throw new ApplicationRuntimeException(AnnotationMessages.unableToCopy(copyOf)); |
51 |
|
|
52 |
1 |
AnnotationUtils.copyBindings(source, cc); |
53 |
|
} |
54 |
2 |
} |
55 |
2 |
} |
56 |
|
} |