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