Clover coverage report - Code Coverage for hivemind-lib release 1.0
Coverage timestamp: Wed Sep 22 2004 08:05:53 EDT
file stats: LOC: 74   Methods: 1
NCLOC: 39   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
BeanFactoryObjectProvider.java 87.5% 92.3% 100% 90.9%
coverage coverage
 1   
 //  Copyright 2004 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.hivemind.lib.factory;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.hivemind.HiveMind;
 19   
 import org.apache.hivemind.Location;
 20   
 import org.apache.hivemind.internal.Module;
 21   
 import org.apache.hivemind.lib.BeanFactory;
 22   
 import org.apache.hivemind.service.ObjectProvider;
 23   
 
 24   
 /**
 25   
  * An {@link org.apache.hivemind.service.ObjectProvider}
 26   
  * that references a named (or named and initialized) bean from a 
 27   
  * {@link org.apache.hivemind.lib.BeanFactory}.  The translator string is of the form:
 28   
  * <code>service-id:name[,initializer]</code>. That is, the text after the colon
 29   
  * is an initializer passed to {@link org.apache.hivemind.lib.BeanFactory#get(String)}.
 30   
  *
 31   
  * @author Howard Lewis Ship
 32   
  */
 33   
 public class BeanFactoryObjectProvider implements ObjectProvider
 34   
 {
 35  4
     public Object provideObject(
 36   
         Module contributingModule,
 37   
         Class propertyType,
 38   
         String inputValue,
 39   
         Location location)
 40   
     {
 41  4
         if (HiveMind.isBlank(inputValue))
 42  1
             return null;
 43   
 
 44  3
         int colonx = inputValue.indexOf(':');
 45   
 
 46  3
         if (colonx < 0)
 47  1
             throw new ApplicationRuntimeException(
 48   
                 FactoryMessages.invalidBeanTranslatorFormat(inputValue),
 49   
                 location,
 50   
                 null);
 51   
 
 52  2
         String serviceId = inputValue.substring(0, colonx);
 53   
 
 54  2
         if (serviceId.length() == 0)
 55  0
             throw new ApplicationRuntimeException(
 56   
                 FactoryMessages.invalidBeanTranslatorFormat(inputValue),
 57   
                 location,
 58   
                 null);
 59   
 
 60  2
         String locator = inputValue.substring(colonx + 1);
 61   
 
 62  2
         if (locator.length() == 0)
 63  1
             throw new ApplicationRuntimeException(
 64   
                 FactoryMessages.invalidBeanTranslatorFormat(inputValue),
 65   
                 location,
 66   
                 null);
 67   
 
 68  1
         BeanFactory f = (BeanFactory) contributingModule.getService(serviceId, BeanFactory.class);
 69   
 
 70  1
         return f.get(locator);
 71   
     }
 72   
 
 73   
 }
 74