View Javadoc

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