Coverage Report - org.mule.module.ibeans.config.IBeanHolderConfigurationBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
IBeanHolderConfigurationBuilder
0%
0/20
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: IBeanHolderConfigurationBuilder.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 package org.mule.module.ibeans.config;
 11  
 
 12  
 import org.mule.api.MuleContext;
 13  
 import org.mule.api.config.ConfigurationException;
 14  
 import org.mule.util.scan.ClasspathScanner;
 15  
 
 16  
 import java.io.IOException;
 17  
 import java.util.HashSet;
 18  
 import java.util.Set;
 19  
 
 20  
 import org.ibeans.annotation.Call;
 21  
 import org.ibeans.annotation.IBeanGroup;
 22  
 import org.ibeans.annotation.Template;
 23  
 import org.ibeans.impl.IBeansNotationHelper;
 24  
 
 25  
 /**
 26  
  * A configuration builder that registers iBean objects on the classpath with the Mule registry.
 27  
  * <p/>
 28  
  * The registry can then be used to query available iBeans.
 29  
  */
 30  
 public class IBeanHolderConfigurationBuilder extends AbstractAnnotationConfigurationBuilder
 31  
 {
 32  
     public static final String IBEAN_HOLDER_PREFIX = "_ibeanHolder.";
 33  
 
 34  
     public IBeanHolderConfigurationBuilder()
 35  0
     {
 36  0
     }
 37  
 
 38  
     public IBeanHolderConfigurationBuilder(String... basepackages)
 39  
     {
 40  0
         super(basepackages);
 41  0
     }
 42  
 
 43  
     public IBeanHolderConfigurationBuilder(ClassLoader classLoader)
 44  
     {
 45  0
         super(classLoader);
 46  0
     }
 47  
 
 48  
     public IBeanHolderConfigurationBuilder(ClassLoader classLoader, String... basepackages)
 49  
     {
 50  0
         super(classLoader, basepackages);
 51  0
     }
 52  
 
 53  
     protected String getScanPackagesProperty()
 54  
     {
 55  0
         return "ibeans.scan.packages";
 56  
     }
 57  
 
 58  
     protected void doConfigure(MuleContext muleContext) throws Exception
 59  
     {
 60  0
         Set<Class> ibeanClasses = new HashSet<Class>();
 61  0
         ClasspathScanner scanner = createClasspathScanner();
 62  
 
 63  
         try
 64  
         {
 65  
             //There will be some overlap here but only
 66  0
             ibeanClasses.addAll(scanner.scanFor(Call.class, ClasspathScanner.INCLUDE_INTERFACE));
 67  0
             ibeanClasses.addAll(scanner.scanFor(Template.class, ClasspathScanner.INCLUDE_INTERFACE));
 68  
             //Some ibeans will extend other iBeans but have not methods of there own
 69  0
             ibeanClasses.addAll(scanner.scanFor(IBeanGroup.class, ClasspathScanner.INCLUDE_INTERFACE));
 70  
         }
 71  0
         catch (IOException e)
 72  
         {
 73  0
             throw new ConfigurationException(e);
 74  0
         }
 75  
 
 76  0
         for (Class ibeanClass : ibeanClasses)
 77  
         {
 78  
 
 79  0
             muleContext.getRegistry().registerObject(IBeansNotationHelper.getIBeanShortID(ibeanClass), new IBeanHolder(ibeanClass));
 80  
         }
 81  0
     }
 82  
 }