activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r910986 - in /activemq/branches/activemq-5.3/activemq-camel/src: main/java/org/apache/activemq/camel/component/ test/java/org/apache/activemq/camel/ test/resources/
Date Wed, 17 Feb 2010 14:19:34 GMT
Author: dejanb
Date: Wed Feb 17 14:19:34 2010
New Revision: 910986

URL: http://svn.apache.org/viewvc?rev=910986&view=rev
Log:
merge -c 910984 - https://issues.apache.org/activemq/browse/AMQ-2611 - camel context and connections

Added:
    activemq/branches/activemq-5.3/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java
      - copied unchanged from r910984, activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java
    activemq/branches/activemq-5.3/activemq-camel/src/test/resources/log4j.properties
      - copied unchanged from r910984, activemq/trunk/activemq-camel/src/test/resources/log4j.properties
Modified:
    activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
    activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java

Modified: activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java?rev=910986&r1=910985&r2=910986&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
(original)
+++ activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java
Wed Feb 17 14:19:34 2010
@@ -16,9 +16,13 @@
  */
 package org.apache.activemq.camel.component;
 
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.activemq.Service;
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.jms.JmsConfiguration;
+import org.springframework.jms.connection.SingleConnectionFactory;
 
 /**
  * The <a href="http://activemq.apache.org/camel/activemq.html">ActiveMQ Component</a>
@@ -26,6 +30,10 @@
  * @version $Revision$
  */
 public class ActiveMQComponent extends JmsComponent {
+    private final CopyOnWriteArrayList<SingleConnectionFactory> singleConnectionFactoryList
=
+        new CopyOnWriteArrayList<SingleConnectionFactory>();
+    private final CopyOnWriteArrayList<Service> pooledConnectionFactoryServiceList
=
+        new CopyOnWriteArrayList<Service>();
     private boolean exposeAllQueues;
     private CamelEndpointLoader endpointLoader;
 
@@ -110,6 +118,14 @@
         }
     }
 
+    protected void addPooledConnectionFactoryService(Service pooledConnectionFactoryService)
{
+        pooledConnectionFactoryServiceList.add(pooledConnectionFactoryService);
+    }
+
+    protected void addSingleConnectionFactory(SingleConnectionFactory singleConnectionFactory)
{
+        singleConnectionFactoryList.add(singleConnectionFactory);
+    }
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();
@@ -119,18 +135,35 @@
         }
     }
 
-
     @Override
     protected void doStop() throws Exception {
         if (endpointLoader != null) {
             endpointLoader.destroy();
             endpointLoader = null;
         }
+        for (Service s : pooledConnectionFactoryServiceList) {
+            s.stop();
+        }
+        pooledConnectionFactoryServiceList.clear();
+        for (SingleConnectionFactory s : singleConnectionFactoryList) {
+            s.destroy();
+        }
+        singleConnectionFactoryList.clear();
         super.doStop();
     }
 
     @Override
+    public void setConfiguration(JmsConfiguration configuration) {
+        if (configuration instanceof ActiveMQConfiguration) {
+            ((ActiveMQConfiguration) configuration).setActiveMQComponent(this);
+        }
+        super.setConfiguration(configuration);
+    }
+
+    @Override
     protected JmsConfiguration createConfiguration() {
-        return new ActiveMQConfiguration();
+        ActiveMQConfiguration answer = new ActiveMQConfiguration();
+        answer.setActiveMQComponent(this);
+        return answer;
     }
 }

Modified: activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java?rev=910986&r1=910985&r2=910986&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
(original)
+++ activemq/branches/activemq-5.3/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java
Wed Feb 17 14:19:34 2010
@@ -20,6 +20,7 @@
 
 import javax.jms.ConnectionFactory;
 
+import org.apache.activemq.Service;
 import org.apache.activemq.spring.ActiveMQConnectionFactory;
 import org.apache.camel.component.jms.JmsConfiguration;
 import org.springframework.jms.connection.SingleConnectionFactory;
@@ -36,6 +37,7 @@
     private boolean usePooledConnection = true;
     private String userName;
     private String password;
+    private ActiveMQComponent activeMQComponent;
 
     public ActiveMQConfiguration() {
     }
@@ -134,6 +136,10 @@
         return answer;
     }
 
+    protected void setActiveMQComponent(ActiveMQComponent activeMQComponent) {
+        this.activeMQComponent = activeMQComponent;
+    }
+
     @Override
     protected ConnectionFactory createConnectionFactory() {
         ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory();
@@ -148,10 +154,18 @@
         }
         answer.setBrokerURL(getBrokerURL());
         if (isUseSingleConnection()) {
-            return new SingleConnectionFactory(answer);
+            SingleConnectionFactory scf = new SingleConnectionFactory(answer);
+            if (activeMQComponent != null) {
+                activeMQComponent.addSingleConnectionFactory(scf);
+            }
+            return scf;
         }
         else if (isUsePooledConnection()) {
-            return createPooledConnectionFactory(answer);
+            ConnectionFactory pcf = createPooledConnectionFactory(answer);
+            if (activeMQComponent != null) {
+                activeMQComponent.addPooledConnectionFactoryService((Service) pcf);
+            }
+            return pcf;
         }
         else {
             return answer;



Mime
View raw message