You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/11/07 16:11:40 UTC
svn commit: r712150 - in
/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms:
JMSConnectionFactory.java JMSSender.java
Author: veithen
Date: Fri Nov 7 07:11:28 2008
New Revision: 712150
URL: http://svn.apache.org/viewvc?rev=712150&view=rev
Log:
JMS transport: more duplicate code elimination; if we already have the right utility methods, we should use them!
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/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=712150&r1=712149&r2=712150&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 Fri Nov 7 07:11:28 2008
@@ -211,32 +211,10 @@
log.info("Connected to the JMS connection factory : " + connFactoryJNDIName);
try {
- QueueConnectionFactory qConFac = null;
- TopicConnectionFactory tConFac = null;
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(getConnectionFactoryType())) {
- qConFac = (QueueConnectionFactory) conFactory;
- } else if (JMSConstants.DESTINATION_TYPE_TOPIC.equals(getConnectionFactoryType())) {
- tConFac = (TopicConnectionFactory) conFactory;
- } else {
- handleException("Unable to determine type of Connection Factory - i.e. Queue/Topic", null);
- }
-
- String user = jndiProperties.get(Context.SECURITY_PRINCIPAL);
- String pass = jndiProperties.get(Context.SECURITY_CREDENTIALS);
-
- if (user != null && pass != null) {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection(user, pass);
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection(user, pass);
- }
- } else {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection();
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection();
- }
- }
+ connection = JMSUtils.createConnection(conFactory,
+ jndiProperties.get(Context.SECURITY_PRINCIPAL),
+ jndiProperties.get(Context.SECURITY_CREDENTIALS),
+ getConnectionFactoryType());
connection.setExceptionListener(this);
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=712150&r1=712149&r2=712150&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 Fri Nov 7 07:11:28 2008
@@ -125,42 +125,13 @@
try {
// create a one time connection and session to be used
Hashtable<String,String> jndiProps = jmsOut.getProperties();
- String user = jndiProps.get(Context.SECURITY_PRINCIPAL);
- String pass = jndiProps.get(Context.SECURITY_CREDENTIALS);
+ connection = JMSUtils.createConnection(jmsOut.getConnectionFactory(),
+ jndiProps.get(Context.SECURITY_PRINCIPAL),
+ jndiProps.get(Context.SECURITY_CREDENTIALS),
+ jmsOut.getDestinationType());
- QueueConnectionFactory qConFac = null;
- TopicConnectionFactory tConFac = null;
-
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(jmsOut.getDestinationType())) {
- qConFac = (QueueConnectionFactory) jmsOut.getConnectionFactory();
- } else if (JMSConstants.DESTINATION_TYPE_TOPIC.equals(jmsOut.getDestinationType())) {
- tConFac = (TopicConnectionFactory) jmsOut.getConnectionFactory();
- } else {
- handleException("Unable to determine type of JMS " +
- "Connection Factory - i.e Queue/Topic");
- }
-
- if (user != null && pass != null) {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection(user, pass);
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection(user, pass);
- }
- } else {
- if (qConFac != null) {
- connection = qConFac.createQueueConnection();
- } else if (tConFac != null) {
- connection = tConFac.createTopicConnection();
- }
- }
-
- if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(jmsOut.getDestinationType())) {
- session = ((QueueConnection)connection).
- createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- } else if (JMSConstants.DESTINATION_TYPE_TOPIC.equals(jmsOut.getDestinationType())) {
- session = ((TopicConnection)connection).
- createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- }
+ session = JMSUtils.createSession(connection, false,
+ Session.AUTO_ACKNOWLEDGE, jmsOut.getDestinationType());
} catch (JMSException e) {
handleException("Error creating a connection/session for : " + targetAddress, e);