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 | |
public NamespaceResourcesImpl(ISpecificationSource source, AssetSource assetSource) |
39 | 0 | { |
40 | 0 | Defense.notNull(source, "source"); |
41 | 0 | Defense.notNull(assetSource, "assetSource"); |
42 | |
|
43 | 0 | _specificationSource = source; |
44 | 0 | _assetSource = assetSource; |
45 | 0 | } |
46 | |
|
47 | |
public ILibrarySpecification findChildLibrarySpecification(Resource parentResource, |
48 | |
String path, Location location) |
49 | |
{ |
50 | 0 | Resource childResource = findSpecificationResource(parentResource, path, location); |
51 | |
|
52 | 0 | return _specificationSource.getLibrarySpecification(childResource); |
53 | |
|
54 | |
} |
55 | |
|
56 | |
private Resource findSpecificationResource(Resource libraryResource, String path, Location location) |
57 | |
{ |
58 | |
|
59 | |
|
60 | 0 | IAsset childAsset = _assetSource.findAsset(libraryResource, path, null, location); |
61 | |
|
62 | 0 | Resource childResource = childAsset.getResourceLocation(); |
63 | |
|
64 | 0 | return childResource; |
65 | |
} |
66 | |
|
67 | |
public IComponentSpecification getPageSpecification(Resource resource, |
68 | |
String specificationPath, Location location) |
69 | |
{ |
70 | 0 | Resource pageSpecificationResource = findSpecificationResource( |
71 | |
resource, |
72 | |
specificationPath, |
73 | |
location); |
74 | |
|
75 | 0 | return _specificationSource.getPageSpecification(pageSpecificationResource); |
76 | |
} |
77 | |
|
78 | |
public IComponentSpecification getComponentSpecification(Resource resource, |
79 | |
String specificationPath, Location location) |
80 | |
{ |
81 | 0 | Resource componentSpecificationResource = findSpecificationResource( |
82 | |
resource, |
83 | |
specificationPath, |
84 | |
location); |
85 | |
|
86 | 0 | return _specificationSource.getComponentSpecification(componentSpecificationResource); |
87 | |
} |
88 | |
|
89 | |
} |