View Javadoc
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.endpoint;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.construct.FlowConstruct;
11  import org.mule.api.endpoint.ImmutableEndpoint;
12  import org.mule.api.processor.MessageProcessor;
13  import org.mule.processor.chain.DefaultMessageProcessorChainBuilder;
14  
15  public class EndpointMessageProcessorChainBuilder extends
16      DefaultMessageProcessorChainBuilder
17  {
18  
19      protected ImmutableEndpoint endpoint;
20  
21      public EndpointMessageProcessorChainBuilder(ImmutableEndpoint endpoint,
22                                                              FlowConstruct flowConstruct)
23      {
24          super(flowConstruct);
25          this.endpoint = endpoint;
26      }
27  
28      @Override
29      protected MessageProcessor initializeMessageProcessor(Object processor) throws MuleException
30      {
31          if (processor instanceof EndpointAware)
32          {
33              ((EndpointAware) processor).setEndpoint(endpoint);
34          }
35          return super.initializeMessageProcessor(processor);
36      }
37  
38  }