camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r577802 - in /activemq/camel/trunk/components/camel-jms: pom.xml src/main/java/org/apache/camel/component/jms/JmsComponent.java
Date Thu, 20 Sep 2007 15:58:07 GMT
Author: chirino
Date: Thu Sep 20 08:58:06 2007
New Revision: 577802

URL: http://svn.apache.org/viewvc?rev=577802&view=rev
Log:
Support autowiring the JMS connection factory via spring

Modified:
    activemq/camel/trunk/components/camel-jms/pom.xml
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java

Modified: activemq/camel/trunk/components/camel-jms/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/pom.xml?rev=577802&r1=577801&r2=577802&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/pom.xml (original)
+++ activemq/camel/trunk/components/camel-jms/pom.xml Thu Sep 20 08:58:06 2007
@@ -95,10 +95,6 @@
         <configuration>
           <childDelegation>false</childDelegation>
           <useFile>true</useFile>
-          <excludes>
-            <!-- TODO - FIXME ASAP -->
-            <exclude>**/JmsRouteUsingSpringWithAutoWireTest.*</exclude>
-          </excludes>
         </configuration>
       </plugin>
 

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?rev=577802&r1=577801&r2=577802&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
(original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
Thu Sep 20 08:58:06 2007
@@ -20,6 +20,10 @@
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
 import static org.apache.camel.util.ObjectHelper.removeStartingCharacters;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.jms.listener.serversession.ServerSessionFactory;
 import org.springframework.jms.support.converter.MessageConverter;
@@ -36,11 +40,12 @@
  * 
  * @version $Revision:520964 $
  */
-public class JmsComponent extends DefaultComponent<JmsExchange> {
+public class JmsComponent extends DefaultComponent<JmsExchange> implements ApplicationContextAware
{
     public static final String QUEUE_PREFIX = "queue:";
     public static final String TOPIC_PREFIX = "topic:";
 
     private JmsConfiguration configuration;
+	private ApplicationContext applicationContext;
 
     public JmsComponent() {
     }
@@ -134,6 +139,15 @@
     public JmsConfiguration getConfiguration() {
         if (configuration == null) {
             configuration = createConfiguration();
+            
+            // If we are being configured with spring... 
+            if( applicationContext !=null ) {
+            	Map beansOfType = applicationContext.getBeansOfType(ConnectionFactory.class);
+            	if( !beansOfType.isEmpty() ) { 
+            		ConnectionFactory cf = (ConnectionFactory) beansOfType.values().iterator().next();
+            		configuration.setConnectionFactory(cf);
+            	}
+            }
         }
         return configuration;
     }
@@ -300,5 +314,9 @@
     protected JmsConfiguration createConfiguration() {
         return new JmsConfiguration();
     }
+
+	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
+		this.applicationContext = applicationContext;
+	}
 
 }



Mime
View raw message