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