Coverage Report - org.mule.config.spring.MuleConfigurationConfigurator
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleConfigurationConfigurator
0%
0/25
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.config.spring;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.config.ConfigurationException;
 11  
 import org.mule.api.config.MuleConfiguration;
 12  
 import org.mule.api.context.MuleContextAware;
 13  
 import org.mule.config.DefaultMuleConfiguration;
 14  
 import org.mule.config.i18n.MessageFactory;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 import org.springframework.beans.factory.SmartFactoryBean;
 19  
 
 20  
 /**
 21  
  * This class is a "SmartFactoryBean" which allows a few XML attributes to be set on the 
 22  
  * otherwise read-only MuleConfiguration.  It looks up the MuleConfiguration from the 
 23  
  * MuleContext and does some class-casting to be able to modify it.  Note that this will
 24  
  * only work if the MuleContext has not yet been started, otherwise the modifications 
 25  
  * will be ignored (and warnings logged).
 26  
  */
 27  0
 public class MuleConfigurationConfigurator implements MuleContextAware, SmartFactoryBean
 28  
 {
 29  
     private MuleContext muleContext;
 30  
     
 31  
     // We instantiate DefaultMuleConfiguration to make sure we get the default values for 
 32  
     // any properties not set by the user.
 33  0
     private DefaultMuleConfiguration config = new DefaultMuleConfiguration();
 34  
 
 35  0
     protected transient Log logger = LogFactory.getLog(MuleConfigurationConfigurator.class);
 36  
 
 37  
     public void setMuleContext(MuleContext context)
 38  
     {
 39  0
         this.muleContext = context;
 40  0
     }
 41  
 
 42  
     public boolean isEagerInit()
 43  
     {
 44  0
         return true;
 45  
     }
 46  
 
 47  
     public boolean isPrototype()
 48  
     {
 49  0
         return false;
 50  
     }
 51  
 
 52  
     public Object getObject() throws Exception
 53  
     {
 54  0
         MuleConfiguration configuration = muleContext.getConfiguration();
 55  0
         if (configuration instanceof DefaultMuleConfiguration)
 56  
         {
 57  0
             DefaultMuleConfiguration defaultConfig = (DefaultMuleConfiguration) configuration;
 58  0
             defaultConfig.setDefaultResponseTimeout(config.getDefaultResponseTimeout());
 59  0
             defaultConfig.setDefaultTransactionTimeout(config.getDefaultTransactionTimeout());
 60  0
             defaultConfig.setShutdownTimeout(config.getShutdownTimeout());
 61  0
             return configuration;
 62  
         }
 63  
         else
 64  
         {
 65  0
             throw new ConfigurationException(MessageFactory.createStaticMessage("Unable to set properties on read-only MuleConfiguration: " + configuration.getClass()));
 66  
         }
 67  
     }
 68  
 
 69  
     public Class<?> getObjectType()
 70  
     {
 71  0
         return MuleConfiguration.class;
 72  
     }
 73  
 
 74  
     public boolean isSingleton()
 75  
     {
 76  0
         return true;
 77  
     }
 78  
 
 79  
     public void setDefaultSynchronousEndpoints(boolean synchronous)
 80  
     {
 81  0
         config.setDefaultSynchronousEndpoints(synchronous);
 82  0
     }
 83  
     
 84  
     public void setDefaultResponseTimeout(int responseTimeout)
 85  
     {
 86  0
         config.setDefaultResponseTimeout(responseTimeout);
 87  0
     }
 88  
     
 89  
     
 90  
     public void setDefaultTransactionTimeout(int defaultTransactionTimeout)
 91  
     {
 92  0
         config.setDefaultTransactionTimeout(defaultTransactionTimeout);
 93  0
     }
 94  
 
 95  
     public void setShutdownTimeout(int shutdownTimeout)
 96  
     {
 97  0
         config.setShutdownTimeout(shutdownTimeout);
 98  0
     }
 99  
 
 100  
 }