1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.services.impl; |
16 |
| |
17 |
| import org.apache.hivemind.Location; |
18 |
| import org.apache.hivemind.Resource; |
19 |
| import org.apache.hivemind.util.Defense; |
20 |
| import org.apache.tapestry.IAsset; |
21 |
| import org.apache.tapestry.asset.AssetSource; |
22 |
| import org.apache.tapestry.engine.ISpecificationSource; |
23 |
| import org.apache.tapestry.services.NamespaceResources; |
24 |
| import org.apache.tapestry.spec.IComponentSpecification; |
25 |
| import org.apache.tapestry.spec.ILibrarySpecification; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public class NamespaceResourcesImpl implements NamespaceResources |
33 |
| { |
34 |
| private final ISpecificationSource _specificationSource; |
35 |
| |
36 |
| private final AssetSource _assetSource; |
37 |
| |
38 |
84
| public NamespaceResourcesImpl(ISpecificationSource source, AssetSource assetSource)
|
39 |
| { |
40 |
84
| Defense.notNull(source, "source");
|
41 |
84
| Defense.notNull(assetSource, "assetSource");
|
42 |
| |
43 |
84
| _specificationSource = source;
|
44 |
84
| _assetSource = assetSource;
|
45 |
| } |
46 |
| |
47 |
36
| public ILibrarySpecification findChildLibrarySpecification(Resource parentResource,
|
48 |
| String path, Location location) |
49 |
| { |
50 |
36
| Resource childResource = findSpecificationResource(parentResource, path, location);
|
51 |
| |
52 |
36
| return _specificationSource.getLibrarySpecification(childResource);
|
53 |
| |
54 |
| } |
55 |
| |
56 |
690
| private Resource findSpecificationResource(Resource libraryResource, String path,
|
57 |
| Location location) |
58 |
| { |
59 |
| |
60 |
| |
61 |
690
| IAsset childAsset = _assetSource.findAsset(libraryResource, path, null, location);
|
62 |
| |
63 |
690
| Resource childResource = childAsset.getResourceLocation();
|
64 |
| |
65 |
690
| return childResource;
|
66 |
| } |
67 |
| |
68 |
88
| public IComponentSpecification getPageSpecification(Resource resource,
|
69 |
| String specificationPath, Location location) |
70 |
| { |
71 |
88
| Resource pageSpecificationResource = findSpecificationResource(
|
72 |
| resource, |
73 |
| specificationPath, |
74 |
| location); |
75 |
| |
76 |
88
| return _specificationSource.getPageSpecification(pageSpecificationResource);
|
77 |
| } |
78 |
| |
79 |
566
| public IComponentSpecification getComponentSpecification(Resource resource,
|
80 |
| String specificationPath, Location location) |
81 |
| { |
82 |
566
| Resource componentSpecificationResource = findSpecificationResource(
|
83 |
| resource, |
84 |
| specificationPath, |
85 |
| location); |
86 |
| |
87 |
566
| return _specificationSource.getComponentSpecification(componentSpecificationResource);
|
88 |
| } |
89 |
| |
90 |
| } |