cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r903769 - in /cxf/branches/2.2.x-fixes: ./ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
Date Wed, 27 Jan 2010 18:00:39 GMT
Author: dkulp
Date: Wed Jan 27 18:00:38 2010
New Revision: 903769

URL: http://svn.apache.org/viewvc?rev=903769&view=rev
Log:
Merged revisions 903762 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r903762 | dkulp | 2010-01-27 12:51:18 -0500 (Wed, 27 Jan 2010) | 2 lines
  
  [CXF-2630] Use some reflection to set the task executor to work with
  both Spring 2.5.x and 3.x
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
    cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java?rev=903769&r1=903768&r2=903769&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
Wed Jan 27 18:00:38 2010
@@ -19,6 +19,7 @@
 package org.apache.cxf.transport.jms;
 
 import java.lang.reflect.Method;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.jms.ConnectionFactory;
@@ -32,6 +33,7 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.springframework.core.task.TaskExecutor;
 import org.springframework.jms.connection.SingleConnectionFactory;
 import org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter;
 import org.springframework.jms.core.JmsTemplate;
@@ -234,6 +236,7 @@
             jmsListener.setDestinationResolver(jmsConfig.getDestinationResolver());
         }
         if (jmsConfig.getTaskExecutor() != null) {
+            setTaskExecutor(jmsListener, jmsConfig.getTaskExecutor());
             jmsListener.setTaskExecutor(jmsConfig.getTaskExecutor());
         } 
         
@@ -249,6 +252,31 @@
         jmsListener.start();
         return jmsListener;
     }
+    
+    private static void setTaskExecutor(DefaultMessageListenerContainer jmsListener, TaskExecutor
exec) {
+        //CXF-2630 - The method sig for DefaultMessageListenerContainer.setTaskExecutor changed
between 
+        //Spring 2.5 and 3.0 and code compiled for one won't run on the other.   Thus, we
need
+        //to revert to using some reflection to make this call
+        Exception ex = null;
+        for (Method m : jmsListener.getClass().getMethods()) {
+            if ("setTaskExecutor".equals(m.getName())
+                && m.getParameterTypes().length == 1
+                && m.getParameterTypes()[0].isInstance(exec)) {
+                try {
+                    m.invoke(jmsListener, exec);
+                    return;
+                } catch (Exception e) {
+                    ex = e;
+                }
+            }
+        }
+        //if we get here, we couldn't find a valid method or something else went wrong
+        if (ex != null) {
+            LOG.log(Level.WARNING, "ERROR_SETTING_TASKEXECUTOR", ex);
+        } else {
+            LOG.log(Level.WARNING, "NO_SETTASKEXECUTOR_METHOD", jmsListener.getClass().getName());
+        }
+    }
 
     /**
      * If the destinationName given is null then a temporary destination is created else
the destination name

Modified: cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties?rev=903769&r1=903768&r2=903769&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
Wed Jan 27 18:00:38 2010
@@ -25,3 +25,5 @@
 JMSCONFIG_REQUIRED = You have to set the property jmsConfig
 INVALID_ENCODING_MSG = Invalid character set {0} in the message.
 INVALID_MESSAGE_TYPE = Invalid configuration for message type, if the MTOM enabled, the message
type should be binary.
+ERROR_SETTING_TASKEXECUTOR = Could not set TaskExecutor on DefaultMessageListenerContainer.
+NO_SETTASKEXECUTOR_METHOD = Could not set TaskExecutor on DefaultMessageListenerContainer
as a setTaskExecutor method could not be found on class {0}.
\ No newline at end of file



Mime
View raw message