You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/03/05 13:36:34 UTC

svn commit: r919389 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/util/concurrent/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/cam...

Author: davsclaus
Date: Fri Mar  5 12:36:33 2010
New Revision: 919389

URL: http://svn.apache.org/viewvc?rev=919389&view=rev
Log:
CAMEL-1588: Improved threads() DSL to let it configure thread pool with using more options.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsDefaultTest.java
      - copied, changed from r919387, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRemoveHeadersTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml
      - copied, changed from r919387, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeaders.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=919389&r1=919388&r2=919389&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Fri Mar  5 12:36:33 2010
@@ -876,7 +876,7 @@
      * Leverages a thread pool for multi threading processing exchanges.
      * <p/>
      * The caller thread will either wait for the async route
-     * to complete or imeddiately continue. If continue the OUT message will
+     * to complete or immediately continue. If continue the OUT message will
      * contain a {@link java.util.concurrent.Future} handle so you can get the real response
      * later using this handle.
      * <p/>
@@ -886,6 +886,9 @@
      *   <li>Provide an IN header with the key {@link org.apache.camel.Exchange#ASYNC_WAIT} with the
      * value containing a type {@link org.apache.camel.WaitForTaskToComplete}. The header will take precedence, if provided.</li>
      * </ul>
+     * <p/>
+     * If no <tt>corePoolSize</tt> is set then a default CachedExecutorService is used which automatic grown and shrinks.
+     * If no <tt>maxPoolSize</tt> is set, then the <tt>corePoolSize</tt> is used as max.
      *
      * @return the builder
      */
@@ -899,6 +902,7 @@
      * Leverages a thread pool for multi threading processing exchanges.
      * <p/>
      * See {@link #threads()} for more details.
+     * If no <tt>maxPoolSize</tt> is set, then the <tt>corePoolSize</tt> is used as max.
      *
      * @param poolSize the core pool size
      * @return the builder
@@ -910,6 +914,22 @@
     }
 
     /**
+     * Leverages a thread pool for multi threading processing exchanges.
+     * <p/>
+     * See {@link #threads()} for more details.
+     *
+     * @param poolSize    the core pool size
+     * @param maxPoolSize the maximum pool size
+     * @return the builder
+     */
+    public ThreadsDefinition threads(int poolSize, int maxPoolSize) {
+        ThreadsDefinition answer = threads();
+        answer.setPoolSize(poolSize);
+        answer.setMaxPoolSize(maxPoolSize);
+        return answer;
+    }
+
+    /**
      * Wraps the sub route using AOP allowing you to do before and after work (AOP around).
      *
      * @return the builder

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java?rev=919389&r1=919388&r2=919389&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java Fri Mar  5 12:36:33 2010
@@ -17,14 +17,17 @@
 package org.apache.camel.model;
 
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.apache.camel.Processor;
 import org.apache.camel.WaitForTaskToComplete;
+import org.apache.camel.builder.xml.TimeUnitAdapter;
 import org.apache.camel.processor.ThreadsProcessor;
 import org.apache.camel.processor.UnitOfWorkProcessor;
 import org.apache.camel.spi.RouteContext;
@@ -46,6 +49,13 @@
     @XmlAttribute(required = false)
     private Integer poolSize;
     @XmlAttribute(required = false)
+    private Integer maxPoolSize;
+    @XmlAttribute(required = false)
+    private Integer keepAliveTime = 60;
+    @XmlAttribute(required = false)
+    @XmlJavaTypeAdapter(TimeUnitAdapter.class)
+    private TimeUnit units = TimeUnit.SECONDS;
+    @XmlAttribute(required = false)
     private WaitForTaskToComplete waitForTaskToComplete = WaitForTaskToComplete.IfReplyExpected;
 
     @Override
@@ -56,8 +66,15 @@
                 throw new IllegalArgumentException("ExecutorServiceRef " + executorServiceRef + " not found in registry.");
             }
         }
-        if (executorService == null && poolSize != null) {
-            executorService = ExecutorServiceHelper.newThreadPool("Threads", poolSize, poolSize);
+        if (executorService == null) {
+            if (poolSize == null || poolSize <= 0) {
+                // use the cached thread pool
+                executorService = ExecutorServiceHelper.newCachedThreadPool("Threads", true);
+            } else {
+                // use a custom pool based on the settings
+                int max = getMaxPoolSize() != null ? getMaxPoolSize() : poolSize;
+                executorService = ExecutorServiceHelper.newThreadPool("Threads", poolSize, max, getKeepAliveTime(), getUnits(), true);
+            }
         }
         Processor childProcessor = routeContext.createProcessor(this);
 
@@ -95,8 +112,9 @@
     }
 
     /**
-     * Setting the core pool size for the underlying {@link java.util.concurrent.ExecutorService}.
+     * Sets the core pool size for the underlying {@link java.util.concurrent.ExecutorService}.
      *
+     * @param poolSize the core pool size to keep minimum in the pool
      * @return the builder
      */
     public ThreadsDefinition poolSize(int poolSize) {
@@ -105,6 +123,40 @@
     }
 
     /**
+     * Sets the maximum pool size for the underlying {@link java.util.concurrent.ExecutorService}.
+     *
+     * @param maxPoolSize the maximum pool size
+     * @return the builder
+     */
+    public ThreadsDefinition maxPoolSize(int maxPoolSize) {
+        setMaxPoolSize(maxPoolSize);
+        return this;
+    }
+
+    /**
+     * Sets the keep alive time for idle threads
+     *
+     * @param keepAliveTime keep alive time
+     * @return the builder
+     */
+    public ThreadsDefinition keepAliveTime(int keepAliveTime) {
+        setKeepAliveTime(keepAliveTime);
+        return this;
+    }
+
+    /**
+     * Sets the keep alive time unit.
+     * By default SECONDS is used.
+     *
+     * @param keepAliveTimeUnits time unit
+     * @return the builder
+     */
+    public ThreadsDefinition units(TimeUnit keepAliveTimeUnits) {
+        setUnits(keepAliveTimeUnits);
+        return this;
+    }
+
+    /**
      * Setting to whether to wait for async tasks to be complete before continuing original route.
      * <p/>
      * Is default <tt>IfReplyExpected</tt>
@@ -148,4 +200,28 @@
     public void setWaitForTaskToComplete(WaitForTaskToComplete waitForTaskToComplete) {
         this.waitForTaskToComplete = waitForTaskToComplete;
     }
+
+    public Integer getMaxPoolSize() {
+        return maxPoolSize;
+    }
+
+    public void setMaxPoolSize(Integer maxPoolSize) {
+        this.maxPoolSize = maxPoolSize;
+    }
+
+    public Integer getKeepAliveTime() {
+        return keepAliveTime;
+    }
+
+    public void setKeepAliveTime(Integer keepAliveTime) {
+        this.keepAliveTime = keepAliveTime;
+    }
+
+    public TimeUnit getUnits() {
+        return units;
+    }
+
+    public void setUnits(TimeUnit units) {
+        this.units = units;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java?rev=919389&r1=919388&r2=919389&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java Fri Mar  5 12:36:33 2010
@@ -129,9 +129,16 @@
      * @param timeUnit      keep alive time unit
      * @param daemon        whether the threads is daemon or not
      * @return the created pool
+     * @throws IllegalArgumentException if parameters is not valid
      */
     public static ExecutorService newThreadPool(final String name, int corePoolSize, int maxPoolSize,
                                                 long keepAliveTime, TimeUnit timeUnit, final boolean daemon) {
+
+        // validate max >= core
+        if (maxPoolSize < corePoolSize) {
+            throw new IllegalArgumentException("MaxPoolSize must be >= corePoolSize, was " + maxPoolSize + " >= " + corePoolSize);
+        }
+
         ThreadPoolExecutor answer = new ThreadPoolExecutor(corePoolSize, maxPoolSize,
                                                            keepAliveTime, timeUnit, new LinkedBlockingQueue<Runnable>());
         answer.setThreadFactory(new ThreadFactory() {

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ThreadsCoreAndMaxPoolInvalidTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return super.isUseRouteBuilder();
+    }
+
+    public void testInvalidSyntax() throws Exception {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:start")
+                        .threads(5, 2)
+                        .to("mock:result");
+                }
+            });
+
+            fail("Should have thrown an exception");
+        } catch (FailedToCreateRouteException e) {
+            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+            assertEquals("MaxPoolSize must be >= corePoolSize, was 2 >= 5", iae.getMessage());
+        }
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ThreadsCoreAndMaxPoolKeepAliveTimeTest extends ContextTestSupport {
+
+    public void testThreadsCoreAndMaxPoolKeepAliveTime() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    // will use a a custom thread pool with 5 in core and 10 as max
+                    .threads(5, 10).keepAliveTime(10).units(TimeUnit.SECONDS)
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ThreadsCoreAndMaxPoolTest extends ContextTestSupport {
+
+    public void testThreadsCoreAndMaxPool() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testThreadsCoreAndMaxPoolBuilder() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    // will use a a custom thread pool with 5 in core and 10 as max
+                    .threads(5, 10)
+                    .to("mock:result");
+
+                from("direct:foo")
+                    // using the builder style
+                    .threads().poolSize(5).maxPoolSize(10)
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ThreadsCorePoolTest extends ContextTestSupport {
+
+    public void testThreadsCorePool() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testThreadsCorePoolBuilder() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    // will use a a custom thread pool with 5 in core and 5 as max
+                    .threads(5)
+                    .to("mock:result");
+
+                from("direct:foo")
+                    // using the builder style
+                    .threads().poolSize(5)
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCorePoolTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ThreadsDefaultTest extends ContextTestSupport {
+
+    public void testThreadsDefault() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    // will use a cached thread pool which can grown/shrink
+                    .threads()
+                    .to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsDefaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ThreadsCoreAndMaxPoolKeepAliveTimeTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringThreadsCoreAndMaxPoolKeepAliveTimeTest extends ThreadsCoreAndMaxPoolKeepAliveTimeTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolKeepAliveTimeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ThreadsCoreAndMaxPoolTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringThreadsCoreAndMaxPoolTest extends ThreadsCoreAndMaxPoolTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCoreAndMaxPoolTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java Fri Mar  5 12:36:33 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ThreadsCorePoolTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringThreadsCorePoolTest extends ThreadsCorePoolTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/ThreadsCorePoolTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsCorePoolTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsDefaultTest.java (from r919387, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRemoveHeadersTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsDefaultTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsDefaultTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRemoveHeadersTest.java&r1=919387&r2=919389&rev=919389&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRemoveHeadersTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThreadsDefaultTest.java Fri Mar  5 12:36:33 2010
@@ -17,14 +17,14 @@
 package org.apache.camel.spring.processor;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.processor.RemoveHeadersTest;
+import org.apache.camel.processor.ThreadsDefaultTest;
 
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringRemoveHeadersTest extends RemoveHeadersTest {
+public class SpringThreadsDefaultTest extends ThreadsDefaultTest {
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/processor/removeHeaders.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/ThreadsDefaultTest.xml");
     }
-    
+
 }
\ No newline at end of file

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml Fri Mar  5 12:36:33 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <threads poolSize="5" maxPoolSize="10" keepAliveTime="10" units="SECONDS"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolKeepAliveTimeTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml Fri Mar  5 12:36:33 2010
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <from uri="direct:foo"/>
+            <threads poolSize="5" maxPoolSize="10"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCoreAndMaxPoolTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml?rev=919389&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml Fri Mar  5 12:36:33 2010
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <from uri="direct:foo"/>
+            <threads poolSize="5"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsCorePoolTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml (from r919387, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeaders.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeaders.xml&r1=919387&r2=919389&rev=919389&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/removeHeaders.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ThreadsDefaultTest.xml Fri Mar  5 12:36:33 2010
@@ -21,18 +21,12 @@
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
-    <!-- START SNIPPET: example -->
+
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:start"/>
-            <!-- remove all dude headers by wildcard -->
-            <removeHeaders pattern="dude*"/>
-            <!-- remove all Carlsberg or Tuborg headers using reg exp -->
-            <removeHeaders pattern="Beer(Carlsberg|Tuborg)"/>
-            <!-- remove the header with the name foo -->
-            <removeHeaders pattern="foo"/>
-            <to uri="mock:end"/>
+            <threads/>
+            <to uri="mock:result"/>
         </route>
     </camelContext>
-    <!-- END SNIPPET: example -->
 </beans>