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