1 /*
2 * $Id: WeblogicJmsTopicResolver.java 7963 2007-08-21 08:53:15Z dirk.olmes $
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.providers.jms.weblogic;
12
13 import org.mule.providers.jms.DefaultJmsTopicResolver;
14 import org.mule.providers.jms.Jms102bSupport;
15 import org.mule.providers.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 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 super(connector);
43 }
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 boolean topic = destination instanceof Topic;
59
60 if (topic && destination instanceof Queue &&
61 getConnector().getJmsSupport() instanceof Jms102bSupport)
62 {
63 try
64 {
65 Method topicMethod = ClassUtils.getPublicMethod(destination.getClass(), "isTopic", PARAMETER_TYPES_NONE);
66
67 topic = ((Boolean) topicMethod.invoke(destination, ClassUtils.NO_ARGS)).booleanValue();
68 }
69 catch (Exception e)
70 {
71 logger.warn(e.getMessage());
72 }
73 }
74 return topic;
75 }
76
77 }