View Javadoc

1   /*
2    * $Id: SynchronousProcessingStrategy.java 22864 2011-09-05 17:18:46Z dfeist $
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.processor.strategy;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.processor.MessageProcessor;
15  import org.mule.api.processor.MessageProcessorBuilder;
16  import org.mule.api.processor.MessageProcessorChainBuilder;
17  import org.mule.api.processor.ProcessingStrategy;
18  
19  import java.util.List;
20  
21  /**
22   * This strategy processes all message processors in the calling thread.
23   */
24  public class SynchronousProcessingStrategy implements ProcessingStrategy
25  {
26      @Override
27      public void configureProcessors(List<MessageProcessor> processors,
28                                      StageNameSource nameSource,
29                                      MessageProcessorChainBuilder chainBuilder,
30                                      MuleContext muleContext)
31      {
32          for (Object processor : processors)
33          {
34              if (processor instanceof MessageProcessor)
35              {
36                  chainBuilder.chain((MessageProcessor) processor);
37              }
38              else if (processor instanceof MessageProcessorBuilder)
39              {
40                  chainBuilder.chain((MessageProcessorBuilder) processor);
41              }
42              else
43              {
44                  throw new IllegalArgumentException(
45                      "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
46              }
47          }
48      }
49  
50  }