1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.service; |
12 | |
|
13 | |
import org.mule.config.MuleProperties; |
14 | |
import org.mule.config.i18n.CoreMessages; |
15 | |
import org.mule.config.i18n.MessageFactory; |
16 | |
import org.mule.impl.MuleSessionHandler; |
17 | |
import org.mule.impl.endpoint.EndpointBuilder; |
18 | |
import org.mule.impl.endpoint.UrlEndpointBuilder; |
19 | |
import org.mule.providers.NullPayload; |
20 | |
import org.mule.umo.UMOComponent; |
21 | |
import org.mule.umo.UMOException; |
22 | |
import org.mule.umo.UMOTransactionConfig; |
23 | |
import org.mule.umo.UMOTransactionFactory; |
24 | |
import org.mule.umo.endpoint.UMOEndpoint; |
25 | |
import org.mule.umo.provider.UMOConnector; |
26 | |
import org.mule.umo.provider.UMOMessageAdapter; |
27 | |
import org.mule.umo.provider.UMOMessageDispatcherFactory; |
28 | |
import org.mule.umo.provider.UMOMessageReceiver; |
29 | |
import org.mule.umo.provider.UMOSessionHandler; |
30 | |
import org.mule.umo.provider.UMOStreamMessageAdapter; |
31 | |
import org.mule.umo.transformer.UMOTransformer; |
32 | |
import org.mule.util.ClassUtils; |
33 | |
import org.mule.util.ObjectFactory; |
34 | |
import org.mule.util.StringUtils; |
35 | |
import org.mule.transaction.XaTransactionFactory; |
36 | |
|
37 | |
import java.io.InputStream; |
38 | |
import java.io.OutputStream; |
39 | |
import java.util.Properties; |
40 | |
|
41 | |
import org.apache.commons.logging.Log; |
42 | |
import org.apache.commons.logging.LogFactory; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public class TransportServiceDescriptor |
55 | |
{ |
56 | |
|
57 | |
|
58 | |
|
59 | 0 | protected static final Log logger = LogFactory.getLog(TransportServiceDescriptor.class); |
60 | |
|
61 | |
private String protocol; |
62 | |
private String serviceLocation; |
63 | |
private String serviceError; |
64 | |
private String serviceFinder; |
65 | |
private String connector; |
66 | |
private String connectorFactory; |
67 | |
private String dispatcherFactory; |
68 | |
private String transactionFactory; |
69 | |
private String messageAdapter; |
70 | |
private String streamMessageAdapter; |
71 | |
private String messageReceiver; |
72 | |
private String transactedMessageReceiver; |
73 | |
private String xaTransactedMessageReceiver; |
74 | |
private String endpointBuilder; |
75 | |
private String sessionHandler; |
76 | |
private String defaultInboundTransformer; |
77 | |
private String defaultOutboundTransformer; |
78 | |
private String defaultResponseTransformer; |
79 | |
private Properties properties; |
80 | |
|
81 | |
private UMOTransformer inboundTransformer; |
82 | |
private UMOTransformer outboundTransformer; |
83 | |
private UMOTransformer responseTransformer; |
84 | |
|
85 | |
private TransportServiceFinder transportServiceFinder; |
86 | |
|
87 | |
public TransportServiceDescriptor(String protocol, String serviceLocation, Properties props) |
88 | 0 | { |
89 | 0 | this.protocol = protocol; |
90 | 0 | this.serviceLocation = serviceLocation; |
91 | 0 | this.properties = props; |
92 | |
|
93 | 0 | serviceError = removeProperty(MuleProperties.CONNECTOR_SERVICE_ERROR); |
94 | 0 | connector = removeProperty(MuleProperties.CONNECTOR_CLASS); |
95 | 0 | connectorFactory = removeProperty(MuleProperties.CONNECTOR_FACTORY); |
96 | 0 | dispatcherFactory = removeProperty(MuleProperties.CONNECTOR_DISPATCHER_FACTORY); |
97 | 0 | transactionFactory = removeProperty(MuleProperties.CONNECTOR_DISPATCHER_FACTORY); |
98 | 0 | messageReceiver = removeProperty(MuleProperties.CONNECTOR_MESSAGE_RECEIVER_CLASS); |
99 | 0 | transactedMessageReceiver = removeProperty(MuleProperties.CONNECTOR_TRANSACTED_MESSAGE_RECEIVER_CLASS); |
100 | 0 | xaTransactedMessageReceiver = removeProperty(MuleProperties.CONNECTOR_XA_TRANSACTED_MESSAGE_RECEIVER_CLASS); |
101 | 0 | messageAdapter = removeProperty(MuleProperties.CONNECTOR_MESSAGE_ADAPTER); |
102 | 0 | streamMessageAdapter = removeProperty(MuleProperties.CONNECTOR_STREAM_MESSAGE_ADAPTER); |
103 | 0 | defaultInboundTransformer = removeProperty(MuleProperties.CONNECTOR_INBOUND_TRANSFORMER); |
104 | 0 | defaultOutboundTransformer = removeProperty(MuleProperties.CONNECTOR_OUTBOUND_TRANSFORMER); |
105 | 0 | defaultResponseTransformer = removeProperty(MuleProperties.CONNECTOR_RESPONSE_TRANSFORMER); |
106 | 0 | endpointBuilder = removeProperty(MuleProperties.CONNECTOR_ENDPOINT_BUILDER); |
107 | 0 | serviceFinder = removeProperty(MuleProperties.CONNECTOR_SERVICE_FINDER); |
108 | 0 | sessionHandler = removeProperty(MuleProperties.CONNECTOR_SESSION_HANDLER); |
109 | 0 | } |
110 | |
|
111 | |
void setOverrides(Properties props) |
112 | |
{ |
113 | 0 | if (props == null || props.size() == 0) |
114 | |
{ |
115 | 0 | return; |
116 | |
} |
117 | 0 | serviceError = props.getProperty(MuleProperties.CONNECTOR_SERVICE_ERROR, serviceError); |
118 | 0 | connector = props.getProperty(MuleProperties.CONNECTOR_CLASS, connector); |
119 | 0 | connectorFactory = props.getProperty(MuleProperties.CONNECTOR_FACTORY, connectorFactory); |
120 | 0 | dispatcherFactory = props.getProperty(MuleProperties.CONNECTOR_DISPATCHER_FACTORY, dispatcherFactory); |
121 | 0 | messageReceiver = props.getProperty(MuleProperties.CONNECTOR_MESSAGE_RECEIVER_CLASS, messageReceiver); |
122 | 0 | transactedMessageReceiver = props.getProperty( |
123 | |
MuleProperties.CONNECTOR_TRANSACTED_MESSAGE_RECEIVER_CLASS, transactedMessageReceiver); |
124 | 0 | xaTransactedMessageReceiver = props.getProperty( |
125 | |
MuleProperties.CONNECTOR_XA_TRANSACTED_MESSAGE_RECEIVER_CLASS, xaTransactedMessageReceiver); |
126 | 0 | messageAdapter = props.getProperty(MuleProperties.CONNECTOR_MESSAGE_ADAPTER, messageAdapter); |
127 | |
|
128 | 0 | String temp = props.getProperty(MuleProperties.CONNECTOR_INBOUND_TRANSFORMER); |
129 | 0 | if (temp != null) |
130 | |
{ |
131 | 0 | defaultInboundTransformer = temp; |
132 | 0 | inboundTransformer = null; |
133 | |
} |
134 | |
|
135 | 0 | temp = props.getProperty(MuleProperties.CONNECTOR_OUTBOUND_TRANSFORMER); |
136 | 0 | if (temp != null) |
137 | |
{ |
138 | 0 | defaultOutboundTransformer = temp; |
139 | 0 | outboundTransformer = null; |
140 | |
} |
141 | |
|
142 | 0 | temp = props.getProperty(MuleProperties.CONNECTOR_RESPONSE_TRANSFORMER); |
143 | 0 | if (temp != null) |
144 | |
{ |
145 | 0 | defaultResponseTransformer = temp; |
146 | 0 | responseTransformer = null; |
147 | |
} |
148 | |
|
149 | 0 | temp = props.getProperty(MuleProperties.CONNECTOR_ENDPOINT_BUILDER); |
150 | 0 | if (temp != null) |
151 | |
{ |
152 | 0 | endpointBuilder = temp; |
153 | |
} |
154 | |
|
155 | 0 | temp = props.getProperty(MuleProperties.CONNECTOR_SERVICE_FINDER); |
156 | 0 | if (temp != null) |
157 | |
{ |
158 | 0 | serviceFinder = temp; |
159 | 0 | transportServiceFinder = null; |
160 | |
} |
161 | 0 | } |
162 | |
|
163 | |
private String removeProperty(String name) |
164 | |
{ |
165 | 0 | String temp = (String) properties.remove(name); |
166 | 0 | if (StringUtils.isEmpty(StringUtils.trim(temp))) |
167 | |
{ |
168 | 0 | return null; |
169 | |
} |
170 | |
else |
171 | |
{ |
172 | 0 | return temp; |
173 | |
} |
174 | |
} |
175 | |
|
176 | |
public String getProtocol() |
177 | |
{ |
178 | 0 | return protocol; |
179 | |
} |
180 | |
|
181 | |
public String getServiceLocation() |
182 | |
{ |
183 | 0 | return serviceLocation; |
184 | |
} |
185 | |
|
186 | |
public String getServiceError() |
187 | |
{ |
188 | 0 | return serviceError; |
189 | |
} |
190 | |
|
191 | |
public String getConnector() |
192 | |
{ |
193 | 0 | return connector; |
194 | |
} |
195 | |
|
196 | |
public String getConnectorFactory() |
197 | |
{ |
198 | 0 | return connectorFactory; |
199 | |
} |
200 | |
|
201 | |
public String getDispatcherFactory() |
202 | |
{ |
203 | 0 | return dispatcherFactory; |
204 | |
} |
205 | |
|
206 | |
public String getMessageReceiver() |
207 | |
{ |
208 | 0 | return messageReceiver; |
209 | |
} |
210 | |
|
211 | |
public String getTransactedMessageReceiver() |
212 | |
{ |
213 | 0 | return transactedMessageReceiver; |
214 | |
} |
215 | |
|
216 | |
public String getXaTransactedMessageReceiver() |
217 | |
{ |
218 | 0 | return xaTransactedMessageReceiver; |
219 | |
} |
220 | |
|
221 | |
public String getDefaultInboundTransformer() |
222 | |
{ |
223 | 0 | return defaultInboundTransformer; |
224 | |
} |
225 | |
|
226 | |
public String getDefaultOutboundTransformer() |
227 | |
{ |
228 | 0 | return defaultOutboundTransformer; |
229 | |
} |
230 | |
|
231 | |
public String getMessageAdapter() |
232 | |
{ |
233 | 0 | return messageAdapter; |
234 | |
} |
235 | |
|
236 | |
public Properties getProperties() |
237 | |
{ |
238 | 0 | return properties; |
239 | |
} |
240 | |
|
241 | |
public String getEndpointBuilder() |
242 | |
{ |
243 | 0 | return endpointBuilder; |
244 | |
} |
245 | |
|
246 | |
public String getServiceFinder() |
247 | |
{ |
248 | 0 | return serviceFinder; |
249 | |
} |
250 | |
|
251 | |
public String getStreamMessageAdapter() |
252 | |
{ |
253 | 0 | return streamMessageAdapter; |
254 | |
} |
255 | |
|
256 | |
public String getTransactionFactory() |
257 | |
{ |
258 | 0 | return transactionFactory; |
259 | |
} |
260 | |
|
261 | |
public TransportServiceFinder getConnectorServiceFinder() |
262 | |
{ |
263 | 0 | return transportServiceFinder; |
264 | |
} |
265 | |
|
266 | |
public String getSessionHandler() |
267 | |
{ |
268 | 0 | return sessionHandler; |
269 | |
} |
270 | |
|
271 | |
public TransportServiceFinder createServiceFinder() throws TransportServiceException |
272 | |
{ |
273 | 0 | if (serviceFinder == null) |
274 | |
{ |
275 | 0 | return null; |
276 | |
} |
277 | 0 | if (transportServiceFinder == null) |
278 | |
{ |
279 | |
try |
280 | |
{ |
281 | 0 | transportServiceFinder = (TransportServiceFinder) ClassUtils.instanciateClass(serviceFinder, |
282 | |
ClassUtils.NO_ARGS); |
283 | |
} |
284 | 0 | catch (Exception e) |
285 | |
{ |
286 | 0 | throw new TransportServiceException( |
287 | |
CoreMessages.cannotInstanciateFinder(serviceFinder), e); |
288 | 0 | } |
289 | |
} |
290 | 0 | return transportServiceFinder; |
291 | |
} |
292 | |
|
293 | |
public String getDefaultResponseTransformer() |
294 | |
{ |
295 | 0 | return defaultResponseTransformer; |
296 | |
} |
297 | |
|
298 | |
public UMOMessageAdapter createMessageAdapter(Object message) throws TransportServiceException |
299 | |
{ |
300 | 0 | return createMessageAdapter(message, messageAdapter); |
301 | |
} |
302 | |
|
303 | |
public UMOStreamMessageAdapter createStreamMessageAdapter(InputStream in, OutputStream out) |
304 | |
throws TransportServiceException |
305 | |
{ |
306 | 0 | if (getStreamMessageAdapter() == null) |
307 | |
{ |
308 | |
|
309 | |
|
310 | 0 | throw new TransportServiceException( |
311 | |
CoreMessages.objectNotSetInService("stream.message.adapter", |
312 | |
this.getProtocol() + " service descriptor")); |
313 | |
} |
314 | |
try |
315 | |
{ |
316 | 0 | if (out == null) |
317 | |
{ |
318 | 0 | return (UMOStreamMessageAdapter) ClassUtils.instanciateClass(streamMessageAdapter, |
319 | |
new Object[]{in}); |
320 | |
} |
321 | |
else |
322 | |
{ |
323 | 0 | return (UMOStreamMessageAdapter) ClassUtils.instanciateClass(streamMessageAdapter, |
324 | |
new Object[]{in, out}); |
325 | |
} |
326 | |
} |
327 | 0 | catch (Exception e) |
328 | |
{ |
329 | 0 | throw new TransportServiceException( |
330 | |
CoreMessages.failedToCreateObjectWith("Message Adapter", streamMessageAdapter), e); |
331 | |
} |
332 | |
} |
333 | |
|
334 | |
protected UMOMessageAdapter createMessageAdapter(Object message, String clazz) |
335 | |
throws TransportServiceException |
336 | |
{ |
337 | 0 | if (message == null) |
338 | |
{ |
339 | 0 | message = NullPayload.getInstance(); |
340 | |
} |
341 | 0 | if (messageAdapter != null) |
342 | |
{ |
343 | |
try |
344 | |
{ |
345 | 0 | return (UMOMessageAdapter) ClassUtils.instanciateClass(clazz, new Object[]{message}); |
346 | |
} |
347 | 0 | catch (Exception e) |
348 | |
{ |
349 | 0 | throw new TransportServiceException( |
350 | |
CoreMessages.failedToCreateObjectWith("Message Adapter", clazz), e); |
351 | |
} |
352 | |
} |
353 | |
else |
354 | |
{ |
355 | 0 | throw new TransportServiceException( |
356 | |
CoreMessages.objectNotSetInService("Message Adapter", this.getProtocol())); |
357 | |
} |
358 | |
} |
359 | |
|
360 | |
public UMOSessionHandler createSessionHandler() throws TransportServiceException |
361 | |
{ |
362 | 0 | if (getSessionHandler() == null) |
363 | |
{ |
364 | 0 | sessionHandler = MuleSessionHandler.class.getName(); |
365 | 0 | if (logger.isDebugEnabled()) |
366 | |
{ |
367 | 0 | logger.debug("No session.handler set in service description, defaulting to: " |
368 | |
+ sessionHandler); |
369 | |
} |
370 | |
} |
371 | |
try |
372 | |
{ |
373 | 0 | return (UMOSessionHandler) ClassUtils.instanciateClass(getSessionHandler(), ClassUtils.NO_ARGS, |
374 | |
getClass()); |
375 | |
} |
376 | 0 | catch (Throwable e) |
377 | |
{ |
378 | 0 | throw new TransportServiceException( |
379 | |
CoreMessages.failedToCreateObjectWith("SessionHandler", sessionHandler), e); |
380 | |
} |
381 | |
} |
382 | |
|
383 | |
public UMOMessageReceiver createMessageReceiver(UMOConnector connector, |
384 | |
UMOComponent component, |
385 | |
UMOEndpoint endpoint) throws UMOException |
386 | |
{ |
387 | |
|
388 | 0 | return createMessageReceiver(connector, component, endpoint, null); |
389 | |
} |
390 | |
|
391 | |
public UMOMessageReceiver createMessageReceiver(UMOConnector connector, |
392 | |
UMOComponent component, |
393 | |
UMOEndpoint endpoint, |
394 | |
Object[] args) throws UMOException |
395 | |
{ |
396 | 0 | String receiverClass = messageReceiver; |
397 | |
|
398 | 0 | if (endpoint.getTransactionConfig() != null |
399 | |
&& endpoint.getTransactionConfig().getAction() != UMOTransactionConfig.ACTION_NONE) |
400 | |
{ |
401 | 0 | boolean xaTx = endpoint.getTransactionConfig().getFactory() instanceof XaTransactionFactory; |
402 | 0 | if (transactedMessageReceiver != null && !xaTx) |
403 | |
{ |
404 | 0 | receiverClass = transactedMessageReceiver; |
405 | |
} |
406 | 0 | else if (xaTransactedMessageReceiver != null && xaTx) |
407 | |
{ |
408 | 0 | receiverClass = xaTransactedMessageReceiver; |
409 | |
} |
410 | |
|
411 | |
} |
412 | |
|
413 | 0 | if (receiverClass != null) |
414 | |
{ |
415 | |
Object[] newArgs; |
416 | |
|
417 | 0 | if (args != null && args.length != 0) |
418 | |
{ |
419 | 0 | newArgs = new Object[3 + args.length]; |
420 | |
} |
421 | |
else |
422 | |
{ |
423 | 0 | newArgs = new Object[3]; |
424 | |
} |
425 | |
|
426 | 0 | newArgs[0] = connector; |
427 | 0 | newArgs[1] = component; |
428 | 0 | newArgs[2] = endpoint; |
429 | |
|
430 | 0 | if (args != null && args.length != 0) |
431 | |
{ |
432 | 0 | System.arraycopy(args, 0, newArgs, 3, newArgs.length - 3); |
433 | |
} |
434 | |
|
435 | |
try |
436 | |
{ |
437 | 0 | return (UMOMessageReceiver) ClassUtils.instanciateClass(receiverClass, newArgs); |
438 | |
} |
439 | 0 | catch (Exception e) |
440 | |
{ |
441 | 0 | throw new TransportServiceException( |
442 | |
CoreMessages.failedToCreateObjectWith("Message Receiver", this.getProtocol()), e); |
443 | |
} |
444 | |
|
445 | |
} |
446 | |
else |
447 | |
{ |
448 | 0 | throw new TransportServiceException( |
449 | |
CoreMessages.objectNotSetInService("Message Receiver", this.getProtocol())); |
450 | |
} |
451 | |
} |
452 | |
|
453 | |
public UMOMessageDispatcherFactory createDispatcherFactory() throws TransportServiceException |
454 | |
{ |
455 | 0 | if (dispatcherFactory != null) |
456 | |
{ |
457 | |
try |
458 | |
{ |
459 | 0 | return (UMOMessageDispatcherFactory) ClassUtils.instanciateClass(dispatcherFactory, |
460 | |
ClassUtils.NO_ARGS); |
461 | |
} |
462 | 0 | catch (Exception e) |
463 | |
{ |
464 | 0 | throw new TransportServiceException( |
465 | |
CoreMessages.failedToCreateObjectWith("Message Dispatcher Factory", dispatcherFactory), |
466 | |
e); |
467 | |
} |
468 | |
} |
469 | |
else |
470 | |
{ |
471 | 0 | throw new TransportServiceException( |
472 | |
CoreMessages.objectNotSetInService("Message Dispatcher Factory", this.getProtocol())); |
473 | |
} |
474 | |
} |
475 | |
|
476 | |
public UMOTransactionFactory createTransactionFactory() throws TransportServiceException |
477 | |
{ |
478 | 0 | if (transactionFactory != null) |
479 | |
{ |
480 | |
try |
481 | |
{ |
482 | 0 | return (UMOTransactionFactory) ClassUtils.instanciateClass(transactionFactory, |
483 | |
ClassUtils.NO_ARGS); |
484 | |
} |
485 | 0 | catch (Exception e) |
486 | |
{ |
487 | 0 | throw new TransportServiceException( |
488 | |
CoreMessages.failedToCreateObjectWith("Transaction Factory", transactionFactory), |
489 | |
e); |
490 | |
} |
491 | |
} |
492 | |
else |
493 | |
{ |
494 | 0 | return null; |
495 | |
} |
496 | |
} |
497 | |
|
498 | |
public UMOConnector createConnector(String protocol) throws TransportServiceException |
499 | |
{ |
500 | |
|
501 | |
UMOConnector connector; |
502 | |
|
503 | |
|
504 | 0 | if (getServiceError() != null) |
505 | |
{ |
506 | 0 | throw new TransportServiceException(MessageFactory.createStaticMessage(getServiceError())); |
507 | |
} |
508 | |
|
509 | |
try |
510 | |
{ |
511 | 0 | if (getConnectorFactory() != null) |
512 | |
{ |
513 | 0 | ObjectFactory factory = (ObjectFactory) ClassUtils.loadClass(getConnectorFactory(), |
514 | |
TransportFactory.class).newInstance(); |
515 | 0 | connector = (UMOConnector) factory.create(); |
516 | |
} |
517 | |
else |
518 | |
{ |
519 | 0 | if (getConnector() != null) |
520 | |
{ |
521 | 0 | connector = (UMOConnector) ClassUtils.loadClass(getConnector(), TransportFactory.class) |
522 | |
.newInstance(); |
523 | |
} |
524 | |
else |
525 | |
{ |
526 | 0 | throw new TransportServiceException( |
527 | |
CoreMessages.objectNotSetInService("Connector", this.getProtocol())); |
528 | |
} |
529 | |
} |
530 | |
} |
531 | 0 | catch (TransportServiceException e) |
532 | |
{ |
533 | 0 | throw e; |
534 | |
} |
535 | 0 | catch (Exception e) |
536 | |
{ |
537 | 0 | throw new TransportServiceException( |
538 | |
CoreMessages.failedToCreateObjectWith("Connector", this.getConnector()), e); |
539 | 0 | } |
540 | |
|
541 | 0 | if (connector.getName() == null) |
542 | |
{ |
543 | 0 | connector.setName("_" + protocol + "Connector#" + connector.hashCode()); |
544 | |
} |
545 | 0 | return connector; |
546 | |
} |
547 | |
|
548 | |
public UMOTransformer createInboundTransformer() throws TransportFactoryException |
549 | |
{ |
550 | 0 | if (inboundTransformer != null) |
551 | |
{ |
552 | 0 | return inboundTransformer; |
553 | |
} |
554 | 0 | if (getDefaultInboundTransformer() != null) |
555 | |
{ |
556 | |
|
557 | 0 | logger.info("Loading default inbound transformer: " + getDefaultInboundTransformer()); |
558 | |
try |
559 | |
{ |
560 | 0 | inboundTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
561 | |
getDefaultInboundTransformer(), ClassUtils.NO_ARGS); |
562 | 0 | return inboundTransformer; |
563 | |
} |
564 | 0 | catch (Exception e) |
565 | |
{ |
566 | 0 | throw new TransportFactoryException( |
567 | |
CoreMessages.failedToLoadTransformer("inbound", this.getDefaultInboundTransformer()), |
568 | |
e); |
569 | |
} |
570 | |
} |
571 | 0 | return null; |
572 | |
} |
573 | |
|
574 | |
public UMOTransformer createNewInboundTransformer() throws TransportFactoryException |
575 | |
{ |
576 | 0 | if (getDefaultInboundTransformer() != null) |
577 | |
{ |
578 | 0 | logger.info("Loading default inbound transformer: " + getDefaultInboundTransformer()); |
579 | |
try |
580 | |
{ |
581 | 0 | inboundTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
582 | |
getDefaultInboundTransformer(), ClassUtils.NO_ARGS); |
583 | 0 | return inboundTransformer; |
584 | |
} |
585 | 0 | catch (Exception e) |
586 | |
{ |
587 | 0 | throw new TransportFactoryException( |
588 | |
CoreMessages.failedToLoadTransformer("inbound", this.getDefaultInboundTransformer()), |
589 | |
e); |
590 | |
} |
591 | |
} |
592 | 0 | return null; |
593 | |
} |
594 | |
|
595 | |
public UMOTransformer createOutboundTransformer() throws TransportFactoryException |
596 | |
{ |
597 | 0 | if (outboundTransformer != null) |
598 | |
{ |
599 | 0 | return outboundTransformer; |
600 | |
} |
601 | 0 | if (getDefaultOutboundTransformer() != null) |
602 | |
{ |
603 | 0 | logger.info("Loading default outbound transformer: " + getDefaultOutboundTransformer()); |
604 | |
try |
605 | |
{ |
606 | 0 | outboundTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
607 | |
getDefaultOutboundTransformer(), ClassUtils.NO_ARGS); |
608 | 0 | return outboundTransformer; |
609 | |
} |
610 | 0 | catch (Exception e) |
611 | |
{ |
612 | 0 | throw new TransportFactoryException( |
613 | |
CoreMessages.failedToLoadTransformer("outbound", this.getDefaultOutboundTransformer()), |
614 | |
e); |
615 | |
} |
616 | |
} |
617 | 0 | return null; |
618 | |
} |
619 | |
|
620 | |
public UMOTransformer createNewOutboundTransformer() throws TransportFactoryException |
621 | |
{ |
622 | 0 | if (getDefaultOutboundTransformer() != null) |
623 | |
{ |
624 | 0 | logger.info("Loading default outbound transformer: " + getDefaultOutboundTransformer()); |
625 | |
try |
626 | |
{ |
627 | 0 | outboundTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
628 | |
getDefaultOutboundTransformer(), ClassUtils.NO_ARGS); |
629 | 0 | return outboundTransformer; |
630 | |
} |
631 | 0 | catch (Exception e) |
632 | |
{ |
633 | 0 | throw new TransportFactoryException( |
634 | |
CoreMessages.failedToLoadTransformer("outbound", this.getDefaultOutboundTransformer()), |
635 | |
e); |
636 | |
} |
637 | |
} |
638 | 0 | return null; |
639 | |
} |
640 | |
|
641 | |
public UMOTransformer createResponseTransformer() throws TransportFactoryException |
642 | |
{ |
643 | 0 | if (responseTransformer != null) |
644 | |
{ |
645 | 0 | return responseTransformer; |
646 | |
} |
647 | 0 | if (getDefaultResponseTransformer() != null) |
648 | |
{ |
649 | 0 | logger.info("Loading default response transformer: " + getDefaultResponseTransformer()); |
650 | |
try |
651 | |
{ |
652 | 0 | responseTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
653 | |
getDefaultResponseTransformer(), ClassUtils.NO_ARGS); |
654 | 0 | return responseTransformer; |
655 | |
} |
656 | 0 | catch (Exception e) |
657 | |
{ |
658 | 0 | throw new TransportFactoryException( |
659 | |
CoreMessages.failedToLoadTransformer("response", this.getDefaultResponseTransformer()), |
660 | |
e); |
661 | |
} |
662 | |
} |
663 | 0 | return null; |
664 | |
} |
665 | |
|
666 | |
public UMOTransformer createNewResponseTransformer() throws TransportFactoryException |
667 | |
{ |
668 | 0 | if (getDefaultResponseTransformer() != null) |
669 | |
{ |
670 | 0 | logger.info("Loading default response transformer: " + getDefaultResponseTransformer()); |
671 | |
try |
672 | |
{ |
673 | 0 | responseTransformer = (UMOTransformer) ClassUtils.instanciateClass( |
674 | |
getDefaultResponseTransformer(), ClassUtils.NO_ARGS); |
675 | 0 | return responseTransformer; |
676 | |
} |
677 | 0 | catch (Exception e) |
678 | |
{ |
679 | 0 | throw new TransportFactoryException( |
680 | |
CoreMessages.failedToLoadTransformer("response", this.getDefaultResponseTransformer()), |
681 | |
e); |
682 | |
} |
683 | |
} |
684 | 0 | return null; |
685 | |
} |
686 | |
|
687 | |
public EndpointBuilder createEndpointBuilder() throws TransportFactoryException |
688 | |
{ |
689 | 0 | if (endpointBuilder == null) |
690 | |
{ |
691 | 0 | logger.debug("Endpoint resolver not set, Loading default resolver: " |
692 | |
+ UrlEndpointBuilder.class.getName()); |
693 | 0 | return new UrlEndpointBuilder(); |
694 | |
} |
695 | |
else |
696 | |
{ |
697 | 0 | logger.debug("Loading endpointUri resolver: " + getEndpointBuilder()); |
698 | |
try |
699 | |
{ |
700 | 0 | return (EndpointBuilder) ClassUtils.instanciateClass(getEndpointBuilder(), ClassUtils.NO_ARGS); |
701 | |
} |
702 | 0 | catch (Exception e) |
703 | |
{ |
704 | 0 | throw new TransportFactoryException( |
705 | |
CoreMessages.failedToLoad("Endpoint Builder: " + getEndpointBuilder()), e); |
706 | |
} |
707 | |
} |
708 | |
} |
709 | |
|
710 | |
public boolean equals(Object o) |
711 | |
{ |
712 | 0 | if (this == o) |
713 | |
{ |
714 | 0 | return true; |
715 | |
} |
716 | 0 | if (!(o instanceof TransportServiceDescriptor)) |
717 | |
{ |
718 | 0 | return false; |
719 | |
} |
720 | |
|
721 | 0 | final TransportServiceDescriptor transportServiceDescriptor = (TransportServiceDescriptor) o; |
722 | |
|
723 | 0 | if (connector != null |
724 | |
? !connector.equals(transportServiceDescriptor.connector) |
725 | |
: transportServiceDescriptor.connector != null) |
726 | |
{ |
727 | 0 | return false; |
728 | |
} |
729 | 0 | if (connectorFactory != null |
730 | |
? !connectorFactory.equals(transportServiceDescriptor.connectorFactory) |
731 | |
: transportServiceDescriptor.connectorFactory != null) |
732 | |
{ |
733 | 0 | return false; |
734 | |
} |
735 | 0 | if (defaultInboundTransformer != null |
736 | |
? !defaultInboundTransformer.equals(transportServiceDescriptor.defaultInboundTransformer) |
737 | |
: transportServiceDescriptor.defaultInboundTransformer != null) |
738 | |
{ |
739 | 0 | return false; |
740 | |
} |
741 | 0 | if (defaultOutboundTransformer != null |
742 | |
? !defaultOutboundTransformer.equals(transportServiceDescriptor.defaultOutboundTransformer) |
743 | |
: transportServiceDescriptor.defaultOutboundTransformer != null) |
744 | |
{ |
745 | 0 | return false; |
746 | |
} |
747 | 0 | if (defaultResponseTransformer != null |
748 | |
? !defaultResponseTransformer.equals(transportServiceDescriptor.defaultResponseTransformer) |
749 | |
: transportServiceDescriptor.defaultResponseTransformer != null) |
750 | |
{ |
751 | 0 | return false; |
752 | |
} |
753 | 0 | if (dispatcherFactory != null |
754 | |
? !dispatcherFactory.equals(transportServiceDescriptor.dispatcherFactory) |
755 | |
: transportServiceDescriptor.dispatcherFactory != null) |
756 | |
{ |
757 | 0 | return false; |
758 | |
} |
759 | 0 | if (endpointBuilder != null |
760 | |
? !endpointBuilder.equals(transportServiceDescriptor.endpointBuilder) |
761 | |
: transportServiceDescriptor.endpointBuilder != null) |
762 | |
{ |
763 | 0 | return false; |
764 | |
} |
765 | 0 | if (messageAdapter != null |
766 | |
? !messageAdapter.equals(transportServiceDescriptor.messageAdapter) |
767 | |
: transportServiceDescriptor.messageAdapter != null) |
768 | |
{ |
769 | 0 | return false; |
770 | |
} |
771 | 0 | if (messageReceiver != null |
772 | |
? !messageReceiver.equals(transportServiceDescriptor.messageReceiver) |
773 | |
: transportServiceDescriptor.messageReceiver != null) |
774 | |
{ |
775 | 0 | return false; |
776 | |
} |
777 | 0 | if (properties != null |
778 | |
? !properties.equals(transportServiceDescriptor.properties) |
779 | |
: transportServiceDescriptor.properties != null) |
780 | |
{ |
781 | 0 | return false; |
782 | |
} |
783 | 0 | if (protocol != null |
784 | |
? !protocol.equals(transportServiceDescriptor.protocol) |
785 | |
: transportServiceDescriptor.protocol != null) |
786 | |
{ |
787 | 0 | return false; |
788 | |
} |
789 | 0 | if (serviceError != null |
790 | |
? !serviceError.equals(transportServiceDescriptor.serviceError) |
791 | |
: transportServiceDescriptor.serviceError != null) |
792 | |
{ |
793 | 0 | return false; |
794 | |
} |
795 | 0 | if (serviceFinder != null |
796 | |
? !serviceFinder.equals(transportServiceDescriptor.serviceFinder) |
797 | |
: transportServiceDescriptor.serviceFinder != null) |
798 | |
{ |
799 | 0 | return false; |
800 | |
} |
801 | 0 | if (serviceLocation != null |
802 | |
? !serviceLocation.equals(transportServiceDescriptor.serviceLocation) |
803 | |
: transportServiceDescriptor.serviceLocation != null) |
804 | |
{ |
805 | 0 | return false; |
806 | |
} |
807 | 0 | if (sessionHandler != null |
808 | |
? !sessionHandler.equals(transportServiceDescriptor.sessionHandler) |
809 | |
: transportServiceDescriptor.sessionHandler != null) |
810 | |
{ |
811 | 0 | return false; |
812 | |
} |
813 | 0 | if (streamMessageAdapter != null |
814 | |
? !streamMessageAdapter.equals(transportServiceDescriptor.streamMessageAdapter) |
815 | |
: transportServiceDescriptor.streamMessageAdapter != null) |
816 | |
{ |
817 | 0 | return false; |
818 | |
} |
819 | 0 | if (transactedMessageReceiver != null |
820 | |
? !transactedMessageReceiver.equals(transportServiceDescriptor.transactedMessageReceiver) |
821 | |
: transportServiceDescriptor.transactedMessageReceiver != null) |
822 | |
{ |
823 | 0 | return false; |
824 | |
} |
825 | 0 | if (transactionFactory != null |
826 | |
? !transactionFactory.equals(transportServiceDescriptor.transactionFactory) |
827 | |
: transportServiceDescriptor.transactionFactory != null) |
828 | |
{ |
829 | 0 | return false; |
830 | |
} |
831 | |
|
832 | 0 | return true; |
833 | |
} |
834 | |
|
835 | |
public int hashCode() |
836 | |
{ |
837 | 0 | int result = (protocol != null ? protocol.hashCode() : 0); |
838 | 0 | result = 29 * result + (serviceLocation != null ? serviceLocation.hashCode() : 0); |
839 | 0 | result = 29 * result + (serviceError != null ? serviceError.hashCode() : 0); |
840 | 0 | result = 29 * result + (serviceFinder != null ? serviceFinder.hashCode() : 0); |
841 | 0 | result = 29 * result + (connector != null ? connector.hashCode() : 0); |
842 | 0 | result = 29 * result + (connectorFactory != null ? connectorFactory.hashCode() : 0); |
843 | 0 | result = 29 * result + (dispatcherFactory != null ? dispatcherFactory.hashCode() : 0); |
844 | 0 | result = 29 * result + (transactionFactory != null ? transactionFactory.hashCode() : 0); |
845 | 0 | result = 29 * result + (messageAdapter != null ? messageAdapter.hashCode() : 0); |
846 | 0 | result = 29 * result + (streamMessageAdapter != null ? streamMessageAdapter.hashCode() : 0); |
847 | 0 | result = 29 * result + (messageReceiver != null ? messageReceiver.hashCode() : 0); |
848 | 0 | result = 29 * result + (transactedMessageReceiver != null ? transactedMessageReceiver.hashCode() : 0); |
849 | 0 | result = 29 * result + (endpointBuilder != null ? endpointBuilder.hashCode() : 0); |
850 | 0 | result = 29 * result + (sessionHandler != null ? sessionHandler.hashCode() : 0); |
851 | 0 | result = 29 * result + (defaultInboundTransformer != null ? defaultInboundTransformer.hashCode() : 0); |
852 | 0 | result = 29 * result |
853 | |
+ (defaultOutboundTransformer != null ? defaultOutboundTransformer.hashCode() : 0); |
854 | 0 | result = 29 * result |
855 | |
+ (defaultResponseTransformer != null ? defaultResponseTransformer.hashCode() : 0); |
856 | 0 | return 29 * result + (properties != null ? properties.hashCode() : 0); |
857 | |
} |
858 | |
|
859 | |
} |