Author: chirino
Date: Wed Apr  4 09:34:34 2007
New Revision: 525552

URL: http://svn.apache.org/viewvc?view=rev&rev=525552
Log:
Eliminate the Endpoint.getExecutorService() leaky abstraction.

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/PollingConsumer.java
    
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
    
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java?view=diff&rev=525552&r1=525551&r2=525552
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java 
(original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Endpoint.java 
Wed Apr  4 09:34:34 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.camel;
 
-import java.util.concurrent.ScheduledExecutorService;
 
 /**
  * Implements the <a 
href="http://activemq.apache.org/camel/message-endpoint.html";>Message 
Endpoint</a>
@@ -63,10 +62,4 @@
      */
     Consumer<E> createConsumer(Processor<E> processor) throws Exception;
 
-    /**
-     * Returns the executor for this endpoint which typically defaults to the 
components executor
-     *
-     * @return the executor for this endpoint
-     */
-    ScheduledExecutorService getExecutorService();
 }

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?view=diff&rev=525552&r1=525551&r2=525552
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
 Wed Apr  4 09:34:34 2007
@@ -28,7 +28,7 @@
 import java.util.concurrent.ScheduledExecutorService;
 
 /**
- * A default endpoint useful for implementation inheritence
+ * A default endpoint useful for implementation inheritance
  * 
  * @version $Revision$
  */

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/PollingConsumer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/PollingConsumer.java?view=diff&rev=525552&r1=525551&r2=525552
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/PollingConsumer.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/PollingConsumer.java
 Wed Apr  4 09:34:34 2007
@@ -35,14 +35,19 @@
 public abstract class PollingConsumer<E extends Exchange> extends 
DefaultConsumer<E> implements Runnable {
     private static final transient Log log = 
LogFactory.getLog(PollingConsumer.class);
 
+    private final ScheduledExecutorService executor;
     private long initialDelay = 1000;
     private long delay = 500;
     private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
     private boolean useFixedDelay;
     private ScheduledFuture<?> future;
 
-    public PollingConsumer(Endpoint<E> endpoint, Processor<E> processor) {
+    public PollingConsumer(Endpoint<E> endpoint, Processor<E> processor, 
ScheduledExecutorService executor) {
         super(endpoint, processor);
+        this.executor=executor;
+        
+        if( executor == null )
+               throw new IllegalArgumentException("A non null 
ScheduledExecutorService must be provided.");
     }
 
     /**
@@ -104,7 +109,6 @@
 
     @Override
     protected void doStart() throws Exception {
-        ScheduledExecutorService executor = getEndpoint().getExecutorService();
         if (isUseFixedDelay()) {
             future = executor.scheduleWithFixedDelay(this, getInitialDelay(), 
getDelay(), getTimeUnit());
         }

Modified: 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java?view=diff&rev=525552&r1=525551&r2=525552
==============================================================================
--- 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
 (original)
+++ 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConsumer.java
 Wed Apr  4 09:34:34 2007
@@ -17,6 +17,15 @@
  */
 package org.apache.camel.component.jpa;
 
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+
+import javax.persistence.EntityManager;
+import javax.persistence.LockModeType;
+import javax.persistence.PersistenceException;
+import javax.persistence.Query;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.PollingConsumer;
@@ -25,13 +34,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.springframework.orm.jpa.JpaCallback;
 
-import javax.persistence.EntityManager;
-import javax.persistence.LockModeType;
-import javax.persistence.PersistenceException;
-import javax.persistence.Query;
-import java.lang.reflect.Method;
-import java.util.List;
-
 /**
  * @version $Revision$
  */
@@ -45,8 +47,8 @@
     private String namedQuery;
     private String nativeQuery;
 
-    public JpaConsumer(JpaEndpoint endpoint, Processor<Exchange> processor) {
-        super(endpoint, processor);
+    public JpaConsumer(JpaEndpoint endpoint, Processor<Exchange> processor, 
ScheduledExecutorService executor) {
+        super(endpoint, processor, executor);
         this.endpoint = endpoint;
         this.template = endpoint.createTransactionStrategy();
     }

Modified: 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java?view=diff&rev=525552&r1=525551&r2=525552
==============================================================================
--- 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
 (original)
+++ 
activemq/camel/trunk/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
 Wed Apr  4 09:34:34 2007
@@ -61,7 +61,7 @@
     }
 
     public Consumer<Exchange> createConsumer(Processor<Exchange> processor) 
throws Exception {
-        JpaConsumer consumer = new JpaConsumer(this, processor);
+        JpaConsumer consumer = new JpaConsumer(this, processor, 
getExecutorService());
         if (consumerProperties != null) {
             IntrospectionSupport.setProperties(consumer, consumerProperties);
         }


Reply via email to