Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 68   Methods: 4
NCLOC: 34   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ContextAssetFactory.java 50% 87.5% 100% 85.7%
coverage coverage
 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.asset;
 16   
 
 17   
 import java.util.Locale;
 18   
 
 19   
 import javax.servlet.ServletContext;
 20   
 
 21   
 import org.apache.hivemind.ApplicationRuntimeException;
 22   
 import org.apache.hivemind.Location;
 23   
 import org.apache.hivemind.Resource;
 24   
 import org.apache.hivemind.util.ContextResource;
 25   
 import org.apache.tapestry.IAsset;
 26   
 
 27   
 /**
 28   
  * For the moment, all "context:" prefixed asset paths are interpreted relative to the servlet
 29   
  * context (the web application's root folder).
 30   
  * 
 31   
  * @author Howard M. Lewis Ship
 32   
  * @since 3.1
 33   
  */
 34   
 public class ContextAssetFactory implements AssetFactory
 35   
 {
 36   
     private ServletContext _servletContext;
 37   
 
 38   
     private String _contextPath;
 39   
 
 40   
     private ContextResource _servletRoot;
 41   
 
 42  5
     public void initializeService()
 43   
     {
 44  5
         _servletRoot = new ContextResource(_servletContext, "/");
 45   
     }
 46   
 
 47  6
     public IAsset createAsset(Resource baseResource, String path, Locale locale, Location location)
 48   
     {
 49  6
         Resource assetResource = _servletRoot.getRelativeResource(path);
 50  6
         Resource localized = assetResource.getLocalization(locale);
 51   
 
 52  6
         if (localized == null)
 53  0
             throw new ApplicationRuntimeException(AssetMessages.missingAsset(path, _servletRoot),
 54   
                     location, null);
 55   
 
 56  6
         return new ContextAsset(_contextPath, (ContextResource) localized, location);
 57   
     }
 58   
 
 59  5
     public void setServletContext(ServletContext servletContext)
 60   
     {
 61  5
         _servletContext = servletContext;
 62   
     }
 63   
 
 64  5
     public void setContextPath(String contextPath)
 65   
     {
 66  5
         _contextPath = contextPath;
 67   
     }
 68   
 }