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: 111   Methods: 6
NCLOC: 63   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
ServiceMapImpl.java 100% 100% 100% 100%
coverage
 1   
 // Copyright 2004, 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 java.util.HashMap;
 18   
 import java.util.Iterator;
 19   
 import java.util.List;
 20   
 import java.util.Map;
 21   
 
 22   
 import org.apache.hivemind.ApplicationRuntimeException;
 23   
 import org.apache.hivemind.ErrorLog;
 24   
 import org.apache.hivemind.HiveMind;
 25   
 import org.apache.tapestry.engine.IEngineService;
 26   
 import org.apache.tapestry.services.ServiceMap;
 27   
 
 28   
 /**
 29   
  * Implementation of {@link org.apache.tapestry.services.ServiceMap}
 30   
  * 
 31   
  * @author Howard Lewis Ship
 32   
  * @since 3.1
 33   
  */
 34   
 public class ServiceMapImpl implements ServiceMap
 35   
 {
 36   
     private List _applicationServices;
 37   
 
 38   
     private List _factoryServices;
 39   
 
 40   
     private ErrorLog _errorLog;
 41   
 
 42   
     /**
 43   
      * Map of {@link IEngineService}keyed on String name.
 44   
      */
 45   
     private Map _services;
 46   
 
 47  56
     public void initializeService()
 48   
     {
 49  56
         Map factoryMap = buildServiceMap(_factoryServices);
 50  56
         Map applicationMap = buildServiceMap(_applicationServices);
 51   
 
 52   
         // Add services from the applicationMap to factoryMap, overwriting
 53   
         // factoryMap entries with the same name.
 54   
 
 55  56
         factoryMap.putAll(applicationMap);
 56   
 
 57  56
         _services = factoryMap;
 58   
     }
 59   
 
 60  112
     private Map buildServiceMap(List services)
 61   
     {
 62  112
         Map result = new HashMap();
 63   
 
 64  112
         Iterator i = services.iterator();
 65  112
         while (i.hasNext())
 66   
         {
 67  422
             IEngineService s = (IEngineService) i.next();
 68  422
             String name = s.getName();
 69   
 
 70  422
             IEngineService existing = (IEngineService) result.get(name);
 71   
 
 72  422
             if (existing != null)
 73   
             {
 74  1
                 _errorLog.error(
 75   
                         ImplMessages.dupeService(name, existing),
 76   
                         HiveMind.getLocation(s),
 77   
                         null);
 78  1
                 continue;
 79   
             }
 80   
 
 81  421
             result.put(name, s);
 82   
         }
 83   
 
 84  112
         return result;
 85   
     }
 86   
 
 87  484
     public IEngineService getService(String name)
 88   
     {
 89  484
         IEngineService result = (IEngineService) _services.get(name);
 90   
 
 91  484
         if (result == null)
 92  1
             throw new ApplicationRuntimeException(ImplMessages.noSuchService(name));
 93   
 
 94  483
         return result;
 95   
     }
 96   
 
 97  56
     public void setApplicationServices(List applicationServices)
 98   
     {
 99  56
         _applicationServices = applicationServices;
 100   
     }
 101   
 
 102  56
     public void setFactoryServices(List factoryServices)
 103   
     {
 104  56
         _factoryServices = factoryServices;
 105   
     }
 106   
 
 107  53
     public void setErrorLog(ErrorLog errorLog)
 108   
     {
 109  53
         _errorLog = errorLog;
 110   
     }
 111   
 }