Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
WeblogicJmsTopicResolver |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.transport.jms.weblogic; | |
8 | ||
9 | import org.mule.transport.jms.DefaultJmsTopicResolver; | |
10 | import org.mule.transport.jms.Jms102bSupport; | |
11 | import org.mule.transport.jms.JmsConnector; | |
12 | import org.mule.util.ClassUtils; | |
13 | ||
14 | import java.lang.reflect.Method; | |
15 | ||
16 | import javax.jms.Destination; | |
17 | import javax.jms.Queue; | |
18 | import javax.jms.Topic; | |
19 | ||
20 | /** | |
21 | * Weblogic-specific JMS topic resolver. Will use reflection and | |
22 | * a vendor API to detect topics. | |
23 | */ | |
24 | public class WeblogicJmsTopicResolver extends DefaultJmsTopicResolver | |
25 | { | |
26 | /** | |
27 | * Cached empty class array, used in the no-args reflective method call. | |
28 | */ | |
29 | 0 | protected static final Class[] PARAMETER_TYPES_NONE = new Class[0]; |
30 | ||
31 | /** | |
32 | * Create an instance of the resolver. | |
33 | * | |
34 | * @param connector owning connector | |
35 | */ | |
36 | public WeblogicJmsTopicResolver(final JmsConnector connector) | |
37 | { | |
38 | 0 | super(connector); |
39 | 0 | } |
40 | ||
41 | ||
42 | /** | |
43 | * For Weblogic 8.x (JMS 1.0.2b) will use Weblogic-specific API call to test for topic. | |
44 | * For Weblogic 9.x and later (JMS 1.1) this call is not required due to the unified | |
45 | * messaging domains. | |
46 | * | |
47 | * @param destination a jms destination to test | |
48 | * @return {@code true} if the destination is a topic | |
49 | */ | |
50 | public boolean isTopic(final Destination destination) | |
51 | { | |
52 | // don't check the invariants, we already handle Weblogic's case here | |
53 | ||
54 | 0 | boolean topic = destination instanceof Topic; |
55 | ||
56 | 0 | if (topic && destination instanceof Queue && |
57 | getConnector().getJmsSupport() instanceof Jms102bSupport) | |
58 | { | |
59 | try | |
60 | { | |
61 | 0 | Method topicMethod = ClassUtils.getPublicMethod(destination.getClass(), "isTopic", PARAMETER_TYPES_NONE); |
62 | ||
63 | 0 | topic = (Boolean) topicMethod.invoke(destination); |
64 | } | |
65 | 0 | catch (Exception e) |
66 | { | |
67 | 0 | logger.warn(e.getMessage()); |
68 | 0 | } |
69 | } | |
70 | 0 | return topic; |
71 | } | |
72 | ||
73 | } |