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