View Javadoc

1   /*
2    * $Id: HttpProxyBuilder.java 21749 2011-04-29 15:20:47Z 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.transport.http.construct.builder;
12  
13  import java.util.Arrays;
14  
15  import org.mule.MessageExchangePattern;
16  import org.mule.api.MuleContext;
17  import org.mule.api.MuleException;
18  import org.mule.api.processor.InterceptingMessageProcessor;
19  import org.mule.api.processor.MessageProcessor;
20  import org.mule.api.transformer.Transformer;
21  import org.mule.construct.builder.AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder;
22  import org.mule.transport.http.construct.HttpProxy;
23  
24  public class HttpProxyBuilder extends
25      AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder<HttpProxyBuilder, HttpProxy>
26  
27  {
28      private InterceptingMessageProcessor cachingMessageProcessor;
29  
30      @Override
31      protected MessageExchangePattern getInboundMessageExchangePattern()
32      {
33          return MessageExchangePattern.REQUEST_RESPONSE;
34      }
35  
36      @Override
37      protected MessageExchangePattern getOutboundMessageExchangePattern()
38      {
39          return MessageExchangePattern.REQUEST_RESPONSE;
40      }
41  
42      public HttpProxyBuilder transformers(final Transformer... outboundTransformers)
43      {
44          this.transformers = Arrays.asList((MessageProcessor[]) outboundTransformers);
45          return this;
46      }
47  
48      public HttpProxyBuilder responseTransformers(final Transformer... outboundResponseTransformers)
49      {
50          this.responseTransformers = Arrays.asList((MessageProcessor[]) outboundResponseTransformers);
51          return this;
52      }
53  
54      public HttpProxyBuilder cachingMessageProcessor(final InterceptingMessageProcessor cachingMessageProcessor)
55      {
56          this.cachingMessageProcessor = cachingMessageProcessor;
57          return this;
58      }
59  
60      @Override
61      protected HttpProxy buildFlowConstruct(final MuleContext muleContext) throws MuleException
62      {
63          return new HttpProxy(name, muleContext, getOrBuildInboundEndpoint(muleContext),
64              getOrBuildOutboundEndpoint(muleContext), transformers, responseTransformers,
65              cachingMessageProcessor);
66      }
67  }