1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.annotations; |
16 |
| |
17 |
| import java.lang.reflect.Method; |
18 |
| |
19 |
| import org.apache.hivemind.Location; |
20 |
| import org.apache.hivemind.Resource; |
21 |
| import org.apache.tapestry.enhance.EnhancementOperation; |
22 |
| import org.apache.tapestry.spec.AssetSpecification; |
23 |
| import org.apache.tapestry.spec.IAssetSpecification; |
24 |
| import org.apache.tapestry.spec.IComponentSpecification; |
25 |
| import org.apache.tapestry.util.DescribedLocation; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| public class AssetAnnotationWorker implements MethodAnnotationEnhancementWorker |
36 |
| { |
37 |
| |
38 |
1
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
|
39 |
| Method method, Location location) |
40 |
| { |
41 |
1
| Asset asset = method.getAnnotation(Asset.class);
|
42 |
1
| String propertyName = AnnotationUtils.getPropertyName(method);
|
43 |
| |
44 |
1
| IAssetSpecification as = new AssetSpecification();
|
45 |
1
| as.setPath(asset.value());
|
46 |
1
| as.setPropertyName(propertyName);
|
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
1
| Resource specResource = spec.getSpecificationLocation();
|
52 |
1
| Location assetLocation = new DescribedLocation(specResource, location.toString());
|
53 |
| |
54 |
1
| as.setLocation(assetLocation);
|
55 |
| |
56 |
1
| spec.addAsset(propertyName, as);
|
57 |
| } |
58 |
| |
59 |
| } |