Clover coverage report - Code Coverage for hivemind release 1.0
Coverage timestamp: Wed Sep 22 2004 08:05:25 EDT
file stats: LOC: 83   Methods: 6
NCLOC: 51   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
CreateClassServiceConstructor.java 100% 91.7% 100% 95%
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.impl;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.hivemind.ClassResolver;
 19   
 import org.apache.hivemind.internal.Module;
 20   
 import org.apache.hivemind.internal.ServiceImplementationConstructor;
 21   
 import org.apache.hivemind.util.ConstructorUtils;
 22   
 
 23   
 /**
 24   
  * Constructs a service by instantiating a class.
 25   
  *
 26   
  * @author Howard Lewis Ship
 27   
  */
 28   
 public final class CreateClassServiceConstructor
 29   
     extends BaseLocatable
 30   
     implements ServiceImplementationConstructor
 31   
 {
 32   
     private Module _contributingModule;
 33   
     private String _instanceClassName;
 34   
     private Class _instanceClass;
 35   
 
 36  319
     public Object constructCoreServiceImplementation()
 37   
     {
 38  319
         Class instanceClass = getInstanceClass();
 39   
 
 40  319
         return ConstructorUtils.invokeConstructor(instanceClass, null);
 41   
     }
 42   
 
 43  319
     private synchronized Class getInstanceClass()
 44   
     {
 45  319
         if (_instanceClass == null)
 46   
         {
 47  318
             try
 48   
             {
 49  318
                 ClassResolver resolver = _contributingModule.getClassResolver();
 50   
 
 51  318
                 _instanceClass = resolver.findClass(_instanceClassName);
 52   
             }
 53   
             catch (Exception ex)
 54   
             {
 55  0
                 throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex);
 56   
             }
 57   
         }
 58   
 
 59  319
         return _instanceClass;
 60   
     }
 61   
 
 62  1
     public Module getContributingModule()
 63   
     {
 64  1
         return _contributingModule;
 65   
     }
 66   
 
 67  1
     public String getInstanceClassName()
 68   
     {
 69  1
         return _instanceClassName;
 70   
     }
 71   
 
 72  719
     public void setContributingModule(Module module)
 73   
     {
 74  719
         _contributingModule = module;
 75   
     }
 76   
 
 77  719
     public void setInstanceClassName(String string)
 78   
     {
 79  719
         _instanceClassName = string;
 80   
     }
 81   
 
 82   
 }
 83