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