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