Coverage Report - nl.beesting.beangenerator.locators.methodlocators.TomcatClassPathResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
TomcatClassPathResolver
91%
10/11
75%
3/4
0
 
 1  
 package nl.beesting.beangenerator.locators.methodlocators;
 2  
 
 3  
 import java.lang.reflect.Method;
 4  
 import java.net.URL;
 5  
 
 6  
 
 7  
 /**
 8  
  * Extension of the AbstractClassPathResolver for use in tomcat will use reflection to add the add
 9  
  * the web applications classes.
 10  
  */
 11  2
 public class TomcatClassPathResolver extends AbstractClassPathResolver {
 12  
 
 13  
     /**
 14  
      * {@inheritDoc}
 15  
      */
 16  
     public void addAddtionalPaths() {
 17  2
         ClassLoader classLoader = getClass().getClassLoader();
 18  2
         URL[] urls = null;
 19  
         try {
 20  2
             Method getUrlsMethod = classLoader.getClass().getMethod("getURLs");
 21  2
             urls = (URL[]) getUrlsMethod.invoke(classLoader);
 22  0
         } catch (Exception e) {
 23  
             // ignore
 24  2
         }
 25  
 
 26  2
         if (urls != null) {
 27  62
             for (URL url : urls) {
 28  60
                 add(url.getFile());
 29  
             }
 30  
         }
 31  2
     }
 32  
 
 33  
 }