Coverage Report - org.mule.config.spring.factories.TransactionalMessageProcessorsFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
TransactionalMessageProcessorsFactoryBean
0%
0/18
0%
0/6
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.processor.MessageProcessor;
 10  
 import org.mule.api.processor.MessageProcessorBuilder;
 11  
 import org.mule.api.processor.MessageProcessors;
 12  
 import org.mule.api.transaction.TransactionConfig;
 13  
 import org.mule.processor.TransactionalInterceptingMessageProcessor;
 14  
 import org.mule.processor.chain.DefaultMessageProcessorChainBuilder;
 15  
 
 16  
 import java.util.List;
 17  
 
 18  
 import org.springframework.beans.factory.FactoryBean;
 19  
 
 20  0
 public class TransactionalMessageProcessorsFactoryBean implements FactoryBean
 21  
 {
 22  
 
 23  
     protected List messageProcessors;
 24  
     protected TransactionConfig transactionConfig;
 25  
 
 26  
     public Class getObjectType()
 27  
     {
 28  0
         return MessageProcessor.class;
 29  
     }
 30  
 
 31  
     public void setMessageProcessors(List messageProcessors)
 32  
     {
 33  0
         this.messageProcessors = messageProcessors;
 34  0
     }
 35  
 
 36  
     public Object getObject() throws Exception
 37  
     {
 38  0
         DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
 39  0
         builder.setName("'transaction' child processor chain");
 40  0
         TransactionalInterceptingMessageProcessor txProcessor = 
 41  
             new TransactionalInterceptingMessageProcessor(transactionConfig);
 42  0
         builder.chain(txProcessor);
 43  0
         for (Object processor : messageProcessors)
 44  
         {
 45  0
             if (processor instanceof MessageProcessor)
 46  
             {
 47  0
                 builder.chain((MessageProcessor) processor);
 48  
             }
 49  0
             else if (processor instanceof MessageProcessorBuilder)
 50  
             {
 51  0
                 builder.chain((MessageProcessorBuilder) processor);
 52  
             }
 53  
             else
 54  
             {
 55  0
                 throw new IllegalArgumentException(
 56  
                     "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
 57  
             }
 58  
         }
 59  0
         return MessageProcessors.lifecyleAwareMessageProcessorWrapper(builder.build());
 60  
     }
 61  
 
 62  
     public boolean isSingleton()
 63  
     {
 64  0
         return false;
 65  
     }
 66  
 
 67  
     public void setTransactionConfig(TransactionConfig transactionConfig)
 68  
     {
 69  0
         this.transactionConfig = transactionConfig;
 70  0
     }
 71  
 }