This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch transport
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-transports.git

commit 20fd54422d101ee896a73487227fa3c95f422c57
Author: Ruwan Linton <ru...@apache.org>
AuthorDate: Mon Oct 12 09:42:52 2009 +0000

    Refactoring of the jms transport get destination (In progress)
---
 .../axis2/transport/jms/JMSConnectionFactory.java  | 22 ++++++++++------
 .../apache/axis2/transport/jms/JMSEndpoint.java    | 29 ++++++++++++++++++++++
 .../axis2/transport/jms/JMSMessageReceiver.java    |  3 ++-
 .../axis2/transport/jms/JMSMessageSender.java      |  3 ++-
 .../org/apache/axis2/transport/jms/JMSSender.java  |  8 +++++-
 5 files changed, 54 insertions(+), 11 deletions(-)

diff --git 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
index de7894a..f7fe745 100644
--- 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
+++ 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
@@ -168,16 +168,12 @@ public class JMSConnectionFactory {
 
     /**
      * Lookup a Destination using this JMS CF definitions and JNDI name
-     * @param name JNDI name of the Destionation
+     * @param destinationName JNDI name of the Destionation
+     * @param destinationType looking up destination type 
      * @return JMS Destination for the given JNDI name or null
      */
-    public Destination getDestination(String name) {
-        try {
-            return JMSUtils.lookup(context, Destination.class, name);
-        } catch (NamingException e) {
-            handleException("Unknown JMS Destination : " + name + " using : " 
+ parameters, e);
-        }
-        return null;
+    public Destination getDestination(String destinationName, String 
destinationType) {
+        return JMSUtils.lookupDestination(context, destinationName, 
destinationType);
     }
 
     /**
@@ -188,6 +184,16 @@ public class JMSConnectionFactory {
         return parameters.get(JMSConstants.PARAM_REPLY_DESTINATION);
     }
 
+    /**
+     * Get the reply destination type from the PARAM_REPLY_DEST_TYPE parameter
+     * @return reply destination defined in the JMS CF
+     */
+    public String getReplyDestinationType() {
+        return parameters.get(JMSConstants.PARAM_REPLY_DEST_TYPE) != null ?
+                parameters.get(JMSConstants.PARAM_REPLY_DEST_TYPE) :
+                JMSConstants.DESTINATION_TYPE_GENERIC;
+    }
+
     private void handleException(String msg, Exception e) {
         log.error(msg, e);
         throw new AxisJMSException(msg, e);
diff --git 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
index 8a38287..eb4a15e 100644
--- 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
+++ 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
@@ -56,6 +56,7 @@ public class JMSEndpoint extends ProtocolEndpoint {
     private String jndiDestinationName;
     private int destinationType = JMSConstants.GENERIC;
     private String jndiReplyDestinationName;
+    private String replyDestinationType = 
JMSConstants.DESTINATION_TYPE_GENERIC;
     private Set<EndpointReference> endpointReferences = new 
HashSet<EndpointReference>();
     private ContentTypeRuleSet contentTypeRuleSet;
     private ServiceTaskManager serviceTaskManager;
@@ -79,10 +80,24 @@ public class JMSEndpoint extends ProtocolEndpoint {
         }
     }
 
+    private void setReplyDestinationType(String destinationType) {
+        if 
(JMSConstants.DESTINATION_TYPE_TOPIC.equalsIgnoreCase(destinationType)) {
+            this.replyDestinationType = JMSConstants.DESTINATION_TYPE_TOPIC;
+        } else if 
(JMSConstants.DESTINATION_TYPE_QUEUE.equalsIgnoreCase(destinationType)) {
+            this.replyDestinationType = JMSConstants.DESTINATION_TYPE_QUEUE;
+        } else {
+            this.replyDestinationType = JMSConstants.DESTINATION_TYPE_GENERIC;
+        }
+    }
+
     public String getJndiReplyDestinationName() {
         return jndiReplyDestinationName;
     }
 
+    public String getReplyDestinationType() {
+        return replyDestinationType;
+    }
+
     @Override
     public EndpointReference[] getEndpointReferences(String ip) {
         return endpointReferences.toArray(new 
EndpointReference[endpointReferences.size()]);
@@ -201,6 +216,20 @@ public class JMSEndpoint extends ProtocolEndpoint {
             log.debug("JMS destination type not given. default queue");
             destinationType = JMSConstants.QUEUE;
         }
+
+        Parameter replyDestTypeParam = 
service.getParameter(JMSConstants.PARAM_REPLY_DEST_TYPE);
+        if (replyDestTypeParam != null) {
+            String paramValue = (String) replyDestTypeParam.getValue();
+            if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) ||
+                    JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue) )  {
+                setReplyDestinationType(paramValue);
+            } else {
+                throw new AxisFault("Invalid destinaton type value " + 
paramValue);
+            }
+        } else {
+            log.debug("JMS reply destination type not given. default queue");
+            destinationType = JMSConstants.QUEUE;
+        }
         
         jndiReplyDestinationName = ParamUtils.getOptionalParam(service,
                 JMSConstants.PARAM_REPLY_DESTINATION);
diff --git 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
index 8cc6113..a85d198 100644
--- 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
+++ 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
@@ -176,7 +176,8 @@ public class JMSMessageReceiver {
             // does the service specify a default reply destination ?
             String jndiReplyDestinationName = 
endpoint.getJndiReplyDestinationName();
             if (jndiReplyDestinationName != null) {
-                replyTo = 
jmsConnectionFactory.getDestination(jndiReplyDestinationName);
+                replyTo = 
jmsConnectionFactory.getDestination(jndiReplyDestinationName,
+                        endpoint.getReplyDestinationType());
             }
 
         }
diff --git 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
index 1c76117..a93df63 100644
--- 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
+++ 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
@@ -87,7 +87,8 @@ public class JMSMessageSender {
         this.session     = jmsConnectionFactory.getSession(connection);
         this.destination =
             jmsConnectionFactory.getSharedDestination() == null ?
-                
jmsConnectionFactory.getDestination(JMSUtils.getDestination(targetAddress)) :
+                
jmsConnectionFactory.getDestination(JMSUtils.getDestination(targetAddress),
+                        JMSConstants.DESTINATION_TYPE_GENERIC) :
                 jmsConnectionFactory.getSharedDestination();
         this.producer = jmsConnectionFactory.getMessageProducer(connection, 
session, destination);
     }
diff --git 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
index 3bb716e..188f3b2 100644
--- 
a/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
+++ 
b/1.0.0/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
@@ -173,9 +173,15 @@ public class JMSSender extends AbstractTransportSender 
implements ManagementSupp
                 replyDestName = jmsConnectionFactory.getReplyToDestination();
             }
 
+            String replyDestType = (String) 
msgCtx.getProperty(JMSConstants.JMS_REPLY_TO_TYPE);
+            if (replyDestType == null && jmsConnectionFactory != null) {
+                replyDestType = jmsConnectionFactory.getReplyDestinationType();
+            }
+
             if (replyDestName != null) {
                 if (jmsConnectionFactory != null) {
-                    replyDestination = 
jmsConnectionFactory.getDestination(replyDestName);
+                    replyDestination = jmsConnectionFactory.getDestination(
+                            replyDestName, replyDestType);
                 } else {
                     replyDestination = 
jmsOut.getReplyDestination(replyDestName);
                 }

Reply via email to