Coverage Report - org.apache.tapestry.services.impl.NamespaceResourcesImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
NamespaceResourcesImpl
0%
0/15
N/A
1
 
 1  
 // Copyright 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 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  
  * Implementation of {@link org.apache.tapestry.services.NamespaceResources}.
 29  
  * 
 30  
  * @author Howard M. Lewis Ship
 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  
         // TODO: This is where we'll play with assets and asset prefixes
 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  
 }