View Javadoc

1   /*
2    * $Id$
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.endpoint;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.construct.FlowConstruct;
15  import org.mule.api.endpoint.ImmutableEndpoint;
16  import org.mule.api.processor.MessageProcessor;
17  import org.mule.processor.builder.InterceptingChainMessageProcessorBuilder;
18  
19  public class EndpointInterceptingChainMessageProcessorBuilder extends
20      InterceptingChainMessageProcessorBuilder
21  {
22  
23      protected ImmutableEndpoint endpoint;
24  
25      public EndpointInterceptingChainMessageProcessorBuilder(ImmutableEndpoint endpoint,
26                                                              FlowConstruct flowConstruct)
27      {
28          super(flowConstruct);
29          this.endpoint = endpoint;
30      }
31  
32      @Override
33      protected MessageProcessor initializeMessageProcessor(Object processor) throws MuleException
34      {
35          if (processor instanceof EndpointAware)
36          {
37              ((EndpointAware) processor).setEndpoint(endpoint);
38          }
39          return super.initializeMessageProcessor(processor);
40      }
41  
42  }