View Javadoc

1   /*
2    * $Id: InterceptingChainLifecycleWrapper.java 20487 2010-12-07 13:45:54Z dirk.olmes $
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.chain;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.processor.MessageProcessor;
16  import org.mule.api.processor.MessageProcessorChain;
17  import org.mule.api.processor.policy.Policies;
18  
19  import java.util.List;
20  
21  /**
22   * Builder needs to return a composite rather than the first MessageProcessor in the
23   * chain. This is so that if this chain is nested in another chain the next
24   * MessageProcessor in the parent chain is not injected into the first in the nested
25   * chain.
26   */
27  public class InterceptingChainLifecycleWrapper extends AbstractMessageProcessorChain
28  {
29      private MessageProcessorChain chain;
30  
31      public InterceptingChainLifecycleWrapper(MessageProcessorChain chain,
32                                               List<MessageProcessor> processors,
33                                               String name)
34      {
35          super(name, processors);
36          this.chain = chain;
37      }
38  
39      @Override
40      public List<MessageProcessor> getMessageProcessors()
41      {
42          return chain.getMessageProcessors();
43      }
44  
45      @Override
46      public String getName()
47      {
48          return chain.getName();
49      }
50  
51      @Override
52      public Policies getPolicies()
53      {
54          return chain.getPolicies();
55      }
56  
57      @Override
58      protected MuleEvent doProcess(MuleEvent event) throws MuleException
59      {
60          return chain.process(event);
61      }
62  
63  }