Coverage Report - org.mule.extras.spring.config.MuleApplicationContext
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleApplicationContext
100%
22/22
67%
4/6
1.286
 
 1  
 /*
 2  
  * $Id: MuleApplicationContext.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  
 
 11  
 package org.mule.extras.spring.config;
 12  
 
 13  
 import java.io.IOException;
 14  
 
 15  
 import org.springframework.beans.BeansException;
 16  
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 17  
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 18  
 import org.springframework.context.support.AbstractXmlApplicationContext;
 19  
 import org.springframework.core.io.Resource;
 20  
 
 21  
 /**
 22  
  * <code>MuleApplicationContext</code> is A Simple extension Application context
 23  
  * that allows rosurces to be loaded from the Classpath of file system using the
 24  
  * MuleBeanDefinitionReader.
 25  
  * 
 26  
  * @see MuleBeanDefinitionReader
 27  
  */
 28  
 public class MuleApplicationContext extends AbstractXmlApplicationContext
 29  
 {
 30  
     private final Resource[] configResources;
 31  
     private final String[] configLocations;
 32  
 
 33  
     public MuleApplicationContext(Resource[] configResources)
 34  
     {
 35  4
         this(configResources, true);
 36  4
     }
 37  
 
 38  
     public MuleApplicationContext(Resource[] configResources, boolean refresh) throws BeansException
 39  4
     {
 40  4
         this.configResources = configResources;
 41  4
         this.configLocations = null;
 42  4
         if (refresh)
 43  
         {
 44  4
             refresh();
 45  
         }
 46  4
     }
 47  
 
 48  
     public MuleApplicationContext(String[] configLocations)
 49  
     {
 50  56
         this(configLocations, true);
 51  56
     }
 52  
 
 53  
     public MuleApplicationContext(String[] configLocations, boolean refresh) throws BeansException
 54  56
     {
 55  56
         this.configLocations = configLocations;
 56  56
         this.configResources = null;
 57  56
         if (refresh)
 58  
         {
 59  56
             refresh();
 60  
         }
 61  56
     }
 62  
 
 63  
     //@Override
 64  
     protected Resource[] getConfigResources() 
 65  
     {
 66  60
         return configResources;
 67  
     }
 68  
     
 69  
     //@Override
 70  
     protected String[] getConfigLocations()
 71  
     {
 72  60
         return configLocations;
 73  
     }
 74  
 
 75  
     //@Override
 76  
     protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException 
 77  
     {
 78  60
         XmlBeanDefinitionReader beanDefinitionReader = new MuleBeanDefinitionReader(beanFactory,
 79  
             configResources != null ? configResources.length : configLocations.length);
 80  
 
 81  60
         initBeanDefinitionReader(beanDefinitionReader);
 82  60
         loadBeanDefinitions(beanDefinitionReader);
 83  60
     }
 84  
 }