Author: davsclaus
Date: Thu Jun 24 13:13:57 2010
New Revision: 957540

URL: http://svn.apache.org/viewvc?rev=957540&view=rev
Log:
CAMEL-2847: Camel thread names is now less verbose as they dont show endpoint 
parameters by default.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java?rev=957540&r1=957539&r2=957540&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
 Thu Jun 24 13:13:57 2010
@@ -161,7 +161,7 @@ public class BeanProcessor extends Servi
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("Processing exchangeId: " + 
exchange.getExchangeId() + " is continued being processed asynchronously");
                 }
-                // the remainder of the routing slip will be completed async
+                // the remainder of the routing will be completed async
                 // so we break out now, then the callback will be invoked 
which then continue routing from where we left here
                 return false;
             }

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?rev=957540&r1=957539&r2=957540&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java 
(original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java 
Thu Jun 24 13:13:57 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.impl;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java?rev=957540&r1=957539&r2=957540&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceStrategy.java
 Thu Jun 24 13:13:57 2010
@@ -92,7 +92,8 @@ public interface ExecutorServiceStrategy
      * The default pattern is: <tt>Camel Thread ${counter} - ${name}</tt>
      * </br>
      * Where <tt>${counter}</tt> is a unique incrementing counter.
-     * And <tt>${name}</tt> is the thread name.
+     * And <tt>${name}</tt> is the regular thread name.
+     * And <tt>${longName}</tt> is the long thread name which can includes 
endpoint parameters etc.
      *
      * @param pattern  the pattern
      * @throws IllegalArgumentException if the pattern is invalid.

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=957540&r1=957539&r2=957540&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
 Thu Jun 24 13:13:57 2010
@@ -69,8 +69,13 @@ public final class ExecutorServiceHelper
             pattern = DEFAULT_PATTERN;
         }
 
+        // we support ${longName} and ${name} as name placeholders
+        String longName = name;
+        String shortName = name.contains("?") ? ObjectHelper.before(name, "?") 
: name;
+
         String answer = pattern.replaceFirst("\\$\\{counter\\}", "" + 
nextThreadCounter());
-        answer = answer.replaceFirst("\\$\\{name\\}", name);
+        answer = answer.replaceFirst("\\$\\{longName\\}", longName);
+        answer = answer.replaceFirst("\\$\\{name\\}", shortName);
         if (answer.indexOf("$") > -1 || answer.indexOf("${") > -1 || 
answer.indexOf("}") > -1) {
             throw new IllegalArgumentException("Pattern is invalid: " + 
pattern);
         }

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java?rev=957540&r1=957539&r2=957540&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceStrategyTest.java
 Thu Jun 24 13:13:57 2010
@@ -51,6 +51,30 @@ public class DefaultExecutorServiceStrat
         assertTrue(bar.endsWith(" - bar"));
     }
 
+    public void testGetThreadNameCustomPatternLongName() throws Exception {
+        context.getExecutorServiceStrategy().setThreadNamePattern("#${counter} 
- ${longName}");
+        String foo = 
context.getExecutorServiceStrategy().getThreadName("foo?beer=Carlsberg");
+        String bar = context.getExecutorServiceStrategy().getThreadName("bar");
+
+        assertNotSame(foo, bar);
+        assertTrue(foo.startsWith("#"));
+        assertTrue(foo.endsWith(" - foo?beer=Carlsberg"));
+        assertTrue(bar.startsWith("#"));
+        assertTrue(bar.endsWith(" - bar"));
+    }
+
+    public void testGetThreadNameCustomPatternWithParameters() throws 
Exception {
+        context.getExecutorServiceStrategy().setThreadNamePattern("#${counter} 
- ${name}");
+        String foo = 
context.getExecutorServiceStrategy().getThreadName("foo?beer=Carlsberg");
+        String bar = context.getExecutorServiceStrategy().getThreadName("bar");
+
+        assertNotSame(foo, bar);
+        assertTrue(foo.startsWith("#"));
+        assertTrue(foo.endsWith(" - foo"));
+        assertTrue(bar.startsWith("#"));
+        assertTrue(bar.endsWith(" - bar"));
+    }
+
     public void testGetThreadNameCustomPatternNoCounter() throws Exception {
         context.getExecutorServiceStrategy().setThreadNamePattern("Cool 
${name}");
         String foo = context.getExecutorServiceStrategy().getThreadName("foo");


Reply via email to