Clover coverage report - Code Coverage for hivemind release 1.1-alpha-1
Coverage timestamp: Tue Jan 18 2005 07:55:08 EST
file stats: LOC: 62   Methods: 1
NCLOC: 32   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
ObjectInstanceObjectProvider.java - 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.hivemind.service.impl;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.hivemind.ClassResolver;
 19   
 import org.apache.hivemind.HiveMind;
 20   
 import org.apache.hivemind.Location;
 21   
 import org.apache.hivemind.internal.Module;
 22   
 import org.apache.hivemind.service.ObjectProvider;
 23   
 
 24   
 /**
 25   
  * Implementation of {@link org.apache.hivemind.service.ObjectProvider}
 26   
  * that instantiates a new instance of a class.  Mapped to the
 27   
  * "instance:" prefix.
 28   
  *
 29   
  * @author Howard Lewis Ship
 30   
  */
 31   
 public class ObjectInstanceObjectProvider implements ObjectProvider
 32   
 {
 33   
 
 34  2
     public Object provideObject(
 35   
         Module contributingModule,
 36   
         Class propertyType,
 37   
         String locator,
 38   
         Location location)
 39   
     {
 40  2
         ClassResolver resolver = contributingModule.getClassResolver();
 41   
 
 42  2
         Class instanceClass = resolver.findClass(locator);
 43   
 
 44  2
         try
 45   
         {
 46  2
             Object result = instanceClass.newInstance();
 47   
 
 48  1
             HiveMind.setLocation(result, location);
 49   
 
 50  1
             return result;
 51   
         }
 52   
         catch (Exception ex)
 53   
         {
 54  1
             throw new ApplicationRuntimeException(
 55   
                 ServiceMessages.errorInstantiatingInstance(instanceClass, ex),
 56   
                 location,
 57   
                 ex);
 58   
         }
 59   
     }
 60   
 
 61   
 }
 62