1
2
3
4
5
6
7
8
9
10
11 package org.mule.endpoint;
12
13 import org.mule.MessageExchangePattern;
14 import org.mule.api.MuleContext;
15 import org.mule.api.MuleEvent;
16 import org.mule.api.MuleException;
17 import org.mule.api.endpoint.EndpointMessageProcessorChainFactory;
18 import org.mule.api.endpoint.EndpointURI;
19 import org.mule.api.endpoint.OutboundEndpoint;
20 import org.mule.api.processor.MessageProcessor;
21 import org.mule.api.retry.RetryPolicyTemplate;
22 import org.mule.api.routing.filter.Filter;
23 import org.mule.api.security.EndpointSecurityFilter;
24 import org.mule.api.transaction.TransactionConfig;
25 import org.mule.api.transformer.Transformer;
26 import org.mule.api.transport.Connector;
27 import org.mule.processor.AbstractRedeliveryPolicy;
28
29 import java.util.List;
30 import java.util.Map;
31
32
33
34
35
36 public class DynamicURIOutboundEndpoint implements OutboundEndpoint
37 {
38
39 private static final long serialVersionUID = -2814979100270307813L;
40
41 protected OutboundEndpoint endpoint;
42 private EndpointURI dynamicEndpointURI;
43
44 public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint)
45 {
46 this.endpoint = endpoint;
47 }
48
49 public DynamicURIOutboundEndpoint(OutboundEndpoint endpoint, EndpointURI dynamicEndpointURI)
50 {
51 this.endpoint = endpoint;
52 setEndpointURI(dynamicEndpointURI);
53 }
54
55 public EndpointURI getEndpointURI()
56 {
57 if (dynamicEndpointURI != null)
58 {
59 return dynamicEndpointURI;
60 }
61 else
62 {
63 return endpoint.getEndpointURI();
64 }
65 }
66
67 public String getAddress()
68 {
69 EndpointURI uri = getEndpointURI();
70 if (uri != null)
71 {
72 return uri.getUri().toString();
73 }
74 else
75 {
76 return null;
77 }
78 }
79
80 public void setEndpointURI(EndpointURI dynamicEndpointURI)
81 {
82 this.dynamicEndpointURI = dynamicEndpointURI;
83 }
84
85 public RetryPolicyTemplate getRetryPolicyTemplate()
86 {
87 return endpoint.getRetryPolicyTemplate();
88 }
89
90 @Override
91 public AbstractRedeliveryPolicy getRedeliveryPolicy()
92 {
93 return endpoint.getRedeliveryPolicy();
94 }
95
96 public Connector getConnector()
97 {
98 return endpoint.getConnector();
99 }
100
101 public String getEncoding()
102 {
103 return endpoint.getEncoding();
104 }
105
106 public String getMimeType()
107 {
108 return endpoint.getMimeType();
109 }
110
111 public Filter getFilter()
112 {
113 return endpoint.getFilter();
114 }
115
116 public String getInitialState()
117 {
118 return endpoint.getInitialState();
119 }
120
121 public MuleContext getMuleContext()
122 {
123 return endpoint.getMuleContext();
124 }
125
126 public String getName()
127 {
128 return endpoint.getName();
129 }
130
131 public Map getProperties()
132 {
133 return endpoint.getProperties();
134 }
135
136 public Object getProperty(Object key)
137 {
138 return endpoint.getProperty(key);
139 }
140
141 public String getProtocol()
142 {
143 return endpoint.getProtocol();
144 }
145
146 public int getResponseTimeout()
147 {
148 return endpoint.getResponseTimeout();
149 }
150
151 public List<Transformer> getResponseTransformers()
152 {
153 return endpoint.getResponseTransformers();
154 }
155
156 public EndpointMessageProcessorChainFactory getMessageProcessorsFactory()
157 {
158 return endpoint.getMessageProcessorsFactory();
159 }
160
161 public List <MessageProcessor> getMessageProcessors()
162 {
163 return endpoint.getMessageProcessors();
164 }
165
166 public List<MessageProcessor> getResponseMessageProcessors()
167 {
168 return endpoint.getResponseMessageProcessors();
169 }
170
171 public EndpointSecurityFilter getSecurityFilter()
172 {
173 return endpoint.getSecurityFilter();
174 }
175
176 public TransactionConfig getTransactionConfig()
177 {
178 return endpoint.getTransactionConfig();
179 }
180
181 public List<Transformer> getTransformers()
182 {
183 return endpoint.getTransformers();
184 }
185
186 public boolean isDeleteUnacceptedMessages()
187 {
188 return endpoint.isDeleteUnacceptedMessages();
189 }
190
191 public boolean isReadOnly()
192 {
193 return endpoint.isReadOnly();
194 }
195
196 public MessageExchangePattern getExchangePattern()
197 {
198 return endpoint.getExchangePattern();
199 }
200
201 public List<String> getResponseProperties()
202 {
203 return endpoint.getResponseProperties();
204 }
205
206 public String getEndpointBuilderName()
207 {
208 return endpoint.getEndpointBuilderName();
209 }
210
211 public boolean isDisableTransportTransformer()
212 {
213 return endpoint.isDisableTransportTransformer();
214 }
215
216 @Override
217 public int hashCode()
218 {
219 final int prime = 31;
220 int result = 1;
221 result = prime * result + ((dynamicEndpointURI == null) ? 0 : dynamicEndpointURI.hashCode());
222 result = prime * result + ((endpoint == null) ? 0 : endpoint.hashCode());
223 return result;
224 }
225
226 @Override
227 public boolean equals(Object obj)
228 {
229 if (this == obj)
230 {
231 return true;
232 }
233 if (obj == null)
234 {
235 return false;
236 }
237 if (getClass() != obj.getClass())
238 {
239 return false;
240 }
241 final DynamicURIOutboundEndpoint other = (DynamicURIOutboundEndpoint) obj;
242 if (dynamicEndpointURI == null)
243 {
244 if (other.dynamicEndpointURI != null)
245 {
246 return false;
247 }
248 }
249 else if (!dynamicEndpointURI.equals(other.dynamicEndpointURI))
250 {
251 return false;
252 }
253 if (endpoint == null)
254 {
255 if (other.endpoint != null)
256 {
257 return false;
258 }
259 }
260 else if (!endpoint.equals(other.endpoint))
261 {
262 return false;
263 }
264 return true;
265 }
266
267 public boolean isProtocolSupported(String protocol)
268 {
269 return getConnector().supportsProtocol(protocol);
270 }
271
272 public MuleEvent process(MuleEvent event) throws MuleException
273 {
274 return endpoint.process(event);
275 }
276
277 }