Clover coverage report - Code Coverage for hivemind release 1.1-alpha-3
Coverage timestamp: Tue Mar 22 2005 09:10:26 EST
file stats: LOC: 77   Methods: 3
NCLOC: 30   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
HiveMindClassPool.java 100% 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 java.util.HashSet;
 18   
 import java.util.Set;
 19   
 
 20   
 import javassist.CannotCompileException;
 21   
 import javassist.ClassPath;
 22   
 import javassist.ClassPool;
 23   
 import javassist.CtClass;
 24   
 import javassist.LoaderClassPath;
 25   
 
 26   
 /**
 27   
  * Used to ensure that {@link javassist.ClassPool#appendClassPath(javassist.ClassPath)}is invoked
 28   
  * with a synchronized lock. Additionally, wraps around a shared
 29   
  * {@link org.apache.hivemind.service.impl.ClassFactoryClassLoader}.
 30   
  * 
 31   
  * @author Howard Lewis Ship
 32   
  */
 33   
 public class HiveMindClassPool extends ClassPool
 34   
 {
 35   
     private ClassFactoryClassLoader _loader = new ClassFactoryClassLoader();
 36   
 
 37   
     /**
 38   
      * Used to identify which class loaders have already been integrated into the pool.
 39   
      */
 40   
     private Set _loaders = new HashSet();
 41   
 
 42  131
     public HiveMindClassPool()
 43   
     {
 44  131
         super(null);
 45   
 
 46  131
         appendClassLoader(Thread.currentThread().getContextClassLoader());
 47   
     }
 48   
 
 49   
     /**
 50   
      * Convienience method for adding to the ClassPath for a particular class loader.
 51   
      */
 52  20298
     public synchronized void appendClassLoader(ClassLoader loader)
 53   
     {
 54  20298
         if (loader == null || loader == _loader || _loaders.contains(loader))
 55  20167
             return;
 56   
 
 57  131
         _loader.addDelegateLoader(loader);
 58   
 
 59  131
         ClassPath path = new LoaderClassPath(loader);
 60   
 
 61  131
         appendClassPath(path);
 62   
 
 63  131
         _loaders.add(loader);
 64   
     }
 65   
 
 66   
     /**
 67   
      * Invoked to convert an fabricated class into a real class. The new classes' class loader will
 68   
      * be the delegating ClassFactoryClassLoader, which has visibility to all class loaders for all
 69   
      * modules.
 70   
      * 
 71   
      * @since 1.1
 72   
      */
 73  1829
     public Class toClass(CtClass ctClass) throws CannotCompileException
 74   
     {
 75  1829
         return ctClass.toClass(_loader);
 76   
     }
 77   
 }