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