Coverage Report - org.mule.transport.jms.weblogic.WeblogicJmsTopicResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
WeblogicJmsTopicResolver
0%
0/11
0%
0/6
2
 
 1  
 /*
 2  
  * $Id: WeblogicJmsTopicResolver.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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  0
     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  0
         super(connector);
 43  0
     }
 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);
 68  
             }
 69  0
             catch (Exception e)
 70  
             {
 71  0
                 logger.warn(e.getMessage()); 
 72  0
             }
 73  
         }
 74  0
         return topic;
 75  
     }
 76  
 
 77  
 }