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: 83   Methods: 4
NCLOC: 44   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.1%
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  121
     public CtClassSource(HiveMindClassPool pool)
 35   
     {
 36  121
         _pool = pool;
 37   
     }
 38   
 
 39  23931
     public CtClass getCtClass(Class searchClass)
 40   
     {
 41  23931
         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  23931
         _pool.appendClassLoader(loader);
 47   
         
 48  23931
         String name = ClassFabUtils.getJavaClassName(searchClass);
 49   
 
 50  23931
         try
 51   
         {
 52  23931
             return _pool.get(name);
 53   
         }
 54   
         catch (NotFoundException ex)
 55   
         {
 56  0
             throw new ApplicationRuntimeException(ServiceMessages.unableToLookupClass(name, ex), ex);
 57   
         }
 58   
     }
 59   
 
 60  1455
     public CtClass newClass(String name, Class superClass)
 61   
     {
 62  1455
         CtClass ctSuperClass = getCtClass(superClass);
 63   
 
 64  1455
         CtClass result = _pool.makeClass(name, ctSuperClass);
 65   
 
 66  1455
         return result;
 67   
     }
 68   
 
 69  1448
     public Class createClass(CtClass ctClass)
 70   
     {
 71   
         // String className = ctClass.getName();
 72   
 
 73  1448
         try
 74   
         {
 75  1448
             return _pool.toClass(ctClass);
 76   
         }
 77   
         catch (Throwable ex)
 78   
         {
 79  3
             throw new ApplicationRuntimeException(ServiceMessages.unableToWriteClass(ctClass, ex),
 80   
                     ex);
 81   
         }
 82   
     }
 83   
 }