Coverage Report - org.mule.config.spring.factories.FlowRefFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
FlowRefFactoryBean
0%
0/11
0%
0/2
0
FlowRefFactoryBean$1
0%
0/2
N/A
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.factories;
 8  
 
 9  
 import org.mule.api.MuleEvent;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.construct.FlowConstruct;
 12  
 import org.mule.api.processor.MessageProcessor;
 13  
 
 14  
 import org.springframework.beans.BeansException;
 15  
 import org.springframework.beans.factory.FactoryBean;
 16  
 import org.springframework.context.ApplicationContext;
 17  
 import org.springframework.context.ApplicationContextAware;
 18  
 
 19  0
 public class FlowRefFactoryBean implements FactoryBean<MessageProcessor>, ApplicationContextAware
 20  
 {
 21  
 
 22  
     private String refName;;
 23  
     private ApplicationContext applicationContext;
 24  
 
 25  
     public void setName(String name)
 26  
     {
 27  0
         this.refName = name;
 28  0
     }
 29  
 
 30  
     public MessageProcessor getObject() throws Exception
 31  
     {
 32  0
         final MessageProcessor processor = ((MessageProcessor) applicationContext.getBean(refName));
 33  0
         if (processor instanceof FlowConstruct)
 34  
         {
 35  
             // If a FlowConstuct is reference then decouple lifcycle/injection
 36  0
             return new MessageProcessor()
 37  0
             {
 38  
                 public MuleEvent process(MuleEvent event) throws MuleException
 39  
                 {
 40  0
                     return processor.process(event);
 41  
                 }
 42  
             };
 43  
         }
 44  
         else
 45  
         {
 46  0
             return processor;
 47  
         }
 48  
     }
 49  
 
 50  
     public boolean isSingleton()
 51  
     {
 52  0
         return false;
 53  
     }
 54  
 
 55  
     public Class<?> getObjectType()
 56  
     {
 57  0
         return MessageProcessor.class;
 58  
     }
 59  
 
 60  
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
 61  
     {
 62  0
         this.applicationContext = applicationContext;
 63  0
     }
 64  
 }