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.MuleContext;
10  import org.mule.api.endpoint.EndpointException;
11  import org.mule.api.endpoint.EndpointURI;
12  import org.mule.api.endpoint.ImmutableEndpoint;
13  import org.mule.api.processor.MessageProcessor;
14  
15  import java.util.Collections;
16  
17  public class EndpointURIEndpointBuilder extends AbstractEndpointBuilder
18  {
19  
20      public EndpointURIEndpointBuilder()
21      {
22          super();
23      }
24  
25      /**
26       * Called from Spring
27       * 
28       * @param global The global endpoint "Policy"
29       */
30      public EndpointURIEndpointBuilder(EndpointURIEndpointBuilder global) throws EndpointException
31      {
32          super();
33          
34          // can't (concisely) use setters where null is a possibility
35          // for consistency, set directly on all fields (this also avoids logic in
36          // getters)
37          uriBuilder = global.uriBuilder;
38          connector = global.connector;
39          name = global.name; // this seems a bit odd, but is tested for in the big
40                              // spring config test case
41          properties = global.properties;
42          transactionConfig = global.transactionConfig;
43          deleteUnacceptedMessages = global.deleteUnacceptedMessages;
44          synchronous = global.synchronous;
45          messageExchangePattern = global.messageExchangePattern;
46          responseTimeout = global.responseTimeout;
47          encoding = global.encoding;
48          retryPolicyTemplate = global.retryPolicyTemplate;
49          messageProcessors = global.messageProcessors;
50          responseMessageProcessors = global.responseMessageProcessors;
51          mimeType = global.mimeType;
52          disableTransportTransformer = global.disableTransportTransformer;
53          transformers = global.transformers;
54          responseTransformers = global.responseTransformers;
55  
56      }
57  
58      public EndpointURIEndpointBuilder(URIBuilder builder)
59      {
60          super();
61          this.uriBuilder = builder;
62          this.muleContext = builder.getMuleContext();
63      }
64  
65      public EndpointURIEndpointBuilder(String address, MuleContext muleContext)
66      {
67          this(new URIBuilder(address, muleContext));
68      }
69  
70      protected EndpointURIEndpointBuilder(EndpointURI endpointURI)
71      {
72          this(new URIBuilder(endpointURI));
73      }
74  
75      public EndpointURIEndpointBuilder(ImmutableEndpoint source)
76      {
77          this(source.getEndpointURI());
78          setName(source.getName());
79          setEncoding(source.getEncoding());
80          setConnector(source.getConnector());
81          setProperties(source.getProperties());
82          setTransactionConfig(source.getTransactionConfig());
83          setDeleteUnacceptedMessages(source.isDeleteUnacceptedMessages());
84          setInitialState(source.getInitialState());
85          setResponseTimeout(source.getResponseTimeout());
86          setRetryPolicyTemplate(source.getRetryPolicyTemplate());
87          setExchangePattern(source.getExchangePattern());
88          setMuleContext(source.getMuleContext());
89          setMessageProcessors(source.getMessageProcessors().isEmpty() ? Collections.<MessageProcessor>emptyList() : source.getMessageProcessors());
90          setResponseMessageProcessors(source.getResponseMessageProcessors().isEmpty() ? Collections.<MessageProcessor>emptyList() : source.getResponseMessageProcessors());
91          setDisableTransportTransformer(source.isDisableTransportTransformer());
92          setMimeType(source.getMimeType());
93      }
94  }