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