Clover coverage report - Code Coverage for hivemind release 1.1-alpha-2
Coverage timestamp: Wed Feb 23 2005 09:59:04 EST
file stats: LOC: 92   Methods: 5
NCLOC: 47   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
CtClassSource.java - 92.3% 100% 94.4%
coverage 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 javassist.CtClass;
 18   
 import javassist.NotFoundException;
 19   
 
 20   
 import org.apache.hivemind.ApplicationRuntimeException;
 21   
 import org.apache.hivemind.service.ClassFabUtils;
 22   
 
 23   
 /**
 24   
  * Wrapper around Javassist's {@link javassist.ClassPool}and our own
 25   
  * {@link org.apache.hivemind.service.impl.ClassFactoryClassLoader}that manages the creation of new
 26   
  * instance of {@link javassist.CtClass}and converts finished CtClass's into instantiable Classes.
 27   
  * 
 28   
  * @author Howard Lewis Ship
 29   
  */
 30   
 public class CtClassSource
 31   
 {
 32   
     private HiveMindClassPool _pool;
 33   
 
 34  131
     public CtClassSource(HiveMindClassPool pool)
 35   
     {
 36  131
         _pool = pool;
 37   
     }
 38   
 
 39  20149
     public CtClass getCtClass(Class searchClass)
 40   
     {
 41  20149
         ClassLoader loader = searchClass.getClassLoader();
 42   
 
 43   
         // Add the class loader for the searchClass to the class pool and
 44   
         // delegating class loader if needed.
 45   
 
 46  20149
         _pool.appendClassLoader(loader);
 47   
 
 48  20149
         String name = ClassFabUtils.getJavaClassName(searchClass);
 49   
 
 50  20149
         try
 51   
         {
 52  20149
             return _pool.get(name);
 53   
         }
 54   
         catch (NotFoundException ex)
 55   
         {
 56  0
             throw new ApplicationRuntimeException(ServiceMessages.unableToLookupClass(name, ex), ex);
 57   
         }
 58   
     }
 59   
 
 60  1828
     public CtClass newClass(String name, Class superClass)
 61   
     {
 62  1828
         CtClass ctSuperClass = getCtClass(superClass);
 63   
 
 64  1828
         return _pool.makeClass(name, ctSuperClass);
 65   
     }
 66   
 
 67   
     /**
 68   
      * Creates a new, empty interace, with the given name.
 69   
      * 
 70   
      * @since 1.1
 71   
      */
 72   
 
 73  9
     public CtClass newInterface(String name)
 74   
     {
 75  9
         return _pool.makeInterface(name);
 76   
     }
 77   
 
 78  1829
     public Class createClass(CtClass ctClass)
 79   
     {
 80   
         // String className = ctClass.getName();
 81   
 
 82  1829
         try
 83   
         {
 84  1829
             return _pool.toClass(ctClass);
 85   
         }
 86   
         catch (Throwable ex)
 87   
         {
 88  3
             throw new ApplicationRuntimeException(ServiceMessages.unableToWriteClass(ctClass, ex),
 89   
                     ex);
 90   
         }
 91   
     }
 92   
 }