Coverage Report - org.mule.config.spring.factories.AsyncMessageProcessorsFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
AsyncMessageProcessorsFactoryBean
0%
0/27
0%
0/10
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.MuleContext;
 14  
 import org.mule.api.NamedObject;
 15  
 import org.mule.api.config.MuleConfiguration;
 16  
 import org.mule.api.config.ThreadingProfile;
 17  
 import org.mule.api.context.MuleContextAware;
 18  
 import org.mule.api.processor.MessageProcessor;
 19  
 import org.mule.api.processor.MessageProcessorBuilder;
 20  
 import org.mule.processor.AsyncInterceptingMessageProcessor;
 21  
 import org.mule.processor.builder.InterceptingChainMessageProcessorBuilder;
 22  
 
 23  
 import org.springframework.beans.factory.FactoryBean;
 24  
 
 25  
 import java.util.List;
 26  
 
 27  0
 public class AsyncMessageProcessorsFactoryBean implements FactoryBean, MuleContextAware, NamedObject
 28  
 {
 29  
 
 30  
     protected MuleContext muleContext;
 31  
 
 32  
     protected List messageProcessors;
 33  
     protected ThreadingProfile threadingProfile;
 34  
     protected String name;
 35  
 
 36  
     public Class getObjectType()
 37  
     {
 38  0
         return MessageProcessor.class;
 39  
     }
 40  
 
 41  
     public void setThreadingProfile(ThreadingProfile threadingProfile)
 42  
     {
 43  0
         this.threadingProfile = threadingProfile;
 44  0
     }
 45  
 
 46  
     public void setMessageProcessors(List messageProcessors)
 47  
     {
 48  0
         this.messageProcessors = messageProcessors;
 49  0
     }
 50  
 
 51  
     public Object getObject() throws Exception
 52  
     {
 53  0
         if (threadingProfile == null)
 54  
         {
 55  0
             threadingProfile = muleContext.getDefaultThreadingProfile();
 56  
         }
 57  
 
 58  0
         InterceptingChainMessageProcessorBuilder builder = new InterceptingChainMessageProcessorBuilder();
 59  0
         final MuleConfiguration config = muleContext.getConfiguration();
 60  0
         final boolean containerMode = config.isContainerMode();
 61  0
         final String threadPrefix = containerMode
 62  
                                         ? String.format("[%s].%s.processor.async", config.getId(), name)
 63  
                                         : String.format("%s.processor.async", name);
 64  0
         AsyncInterceptingMessageProcessor asyncProcessor = new AsyncInterceptingMessageProcessor(threadingProfile,
 65  
                                                                                                  threadPrefix,
 66  
                                                                                                  config.getShutdownTimeout());
 67  0
         builder.chain(asyncProcessor);
 68  0
         for (Object processor : messageProcessors)
 69  
         {
 70  0
             if (processor instanceof MessageProcessor)
 71  
             {
 72  0
                 builder.chain((MessageProcessor) processor);
 73  
             }
 74  0
             else if (processor instanceof MessageProcessorBuilder)
 75  
             {
 76  0
                 builder.chain((MessageProcessorBuilder) processor);
 77  
             }
 78  
             else
 79  
             {
 80  0
                 throw new IllegalArgumentException(
 81  
                     "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
 82  
             }
 83  
         }
 84  0
         return builder.build();
 85  
     }
 86  
 
 87  
     public boolean isSingleton()
 88  
     {
 89  0
         return false;
 90  
     }
 91  
 
 92  
     public void setMuleContext(MuleContext context)
 93  
     {
 94  0
         this.muleContext = context;
 95  0
     }
 96  
 
 97  
     public String getName()
 98  
     {
 99  0
         return name;
 100  
     }
 101  
 
 102  
     public void setName(String name)
 103  
     {
 104  0
         this.name = name;
 105  0
     }
 106  
 
 107  
 }