Author: ruwan
Date: Mon Oct 12 09:42:51 2009
New Revision: 824281
URL: http://svn.apache.org/viewvc?rev=824281&view=rev
Log:
Refactoring of the jms transport get destination (In progress)
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java?rev=824281&r1=824280&r2=824281&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSConnectionFactory.java
Mon Oct 12 09:42:51 2009
@@ -168,16 +168,12 @@
/**
* 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 @@
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);
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java?rev=824281&r1=824280&r2=824281&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java
Mon Oct 12 09:42:51 2009
@@ -56,6 +56,7 @@
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 @@
}
}
+ 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 @@
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);
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java?rev=824281&r1=824280&r2=824281&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageReceiver.java
Mon Oct 12 09:42:51 2009
@@ -176,7 +176,8 @@
// 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());
}
}
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java?rev=824281&r1=824280&r2=824281&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSMessageSender.java
Mon Oct 12 09:42:51 2009
@@ -87,7 +87,8 @@
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);
}
Modified:
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java?rev=824281&r1=824280&r2=824281&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
Mon Oct 12 09:42:51 2009
@@ -173,9 +173,15 @@
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);
}