Clover coverage report - Code Coverage for hivemind release 1.0-rc-2
Coverage timestamp: Sat Sep 11 2004 09:09:48 EDT
file stats: LOC: 68   Methods: 3
NCLOC: 28   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 50% 87.5% 100% 84.6%
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.service.impl;
 16   
 
 17   
 import java.util.HashSet;
 18   
 import java.util.Set;
 19   
 
 20   
 import javassist.ClassPath;
 21   
 import javassist.ClassPool;
 22   
 import javassist.LoaderClassPath;
 23   
 
 24   
 /**
 25   
  * Used to ensure that {@link javassist.ClassPool#appendClassPath(javassist.ClassPath)} is
 26   
  * invoked with a synchronized lock. Additionally, wraps around a shared
 27   
  * {@link org.apache.hivemind.service.impl.ClassFactoryClassLoader}.
 28   
  *
 29   
  * @author Howard Lewis Ship
 30   
  */
 31   
 public class HiveMindClassPool extends ClassPool
 32   
 {
 33   
     private ClassFactoryClassLoader _loader = new ClassFactoryClassLoader();
 34   
 
 35   
     /**
 36   
      * Used to identify which class loaders have already been integrated into the pool.
 37   
      */
 38   
     private Set _loaders = new HashSet();
 39   
 
 40  113
     public HiveMindClassPool()
 41   
     {
 42  113
         super(null);
 43   
     }
 44   
 
 45   
     /**
 46   
      * Convienience method for adding to the ClassPath for a particular
 47   
      * class loader.
 48   
      */
 49  113
     public synchronized void appendClassLoader(ClassLoader loader)
 50   
     {
 51  113
         if (_loaders.contains(loader))
 52  0
             return;
 53   
 
 54  113
         _loader.addDelegateLoader(loader);
 55   
 
 56  113
         ClassPath path = new LoaderClassPath(loader);
 57   
 
 58  113
         appendClassPath(path);
 59   
 
 60  113
         _loaders.add(loader);
 61   
     }
 62   
 
 63  1362
     public Class loadClass(String name, byte[] bytecodes)
 64   
     {
 65  1362
         return _loader.loadClass(name, bytecodes);
 66   
     }
 67   
 }
 68