camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: Optimize toString on a consumer/producer
Date Fri, 12 Feb 2016 17:03:49 GMT
Optimize toString on a consumer/producer


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c12fdebd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c12fdebd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c12fdebd

Branch: refs/heads/camel-2.16.x
Commit: c12fdebdbc9f200332574778304bd75b1ccf3947
Parents: 8cae338
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Feb 12 18:02:54 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Feb 12 18:03:41 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultConsumer.java   | 6 +++++-
 .../src/main/java/org/apache/camel/impl/DefaultProducer.java   | 6 +++++-
 .../main/java/org/apache/camel/processor/SendProcessor.java    | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c12fdebd/camel-core/src/main/java/org/apache/camel/impl/DefaultConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultConsumer.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultConsumer.java
index 7e533e5..7066c35 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultConsumer.java
@@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
  */
 public class DefaultConsumer extends ServiceSupport implements Consumer, RouteAware {
     protected final Logger log = LoggerFactory.getLogger(getClass());
+    private transient String consumerToString;
     private final Endpoint endpoint;
     private final Processor processor;
     private volatile AsyncProcessor asyncProcessor;
@@ -55,7 +56,10 @@ public class DefaultConsumer extends ServiceSupport implements Consumer,
RouteAw
 
     @Override
     public String toString() {
-        return "Consumer[" + URISupport.sanitizeUri(endpoint.getEndpointUri()) + "]";
+        if (consumerToString == null) {
+            consumerToString = "Consumer[" + URISupport.sanitizeUri(endpoint.getEndpointUri())
+ "]";
+        }
+        return consumerToString;
     }
 
     public Route getRoute() {

http://git-wip-us.apache.org/repos/asf/camel/blob/c12fdebd/camel-core/src/main/java/org/apache/camel/impl/DefaultProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultProducer.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultProducer.java
index 7b94e47..c241b33 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultProducer.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class DefaultProducer extends ServiceSupport implements Producer {
     protected final Logger log = LoggerFactory.getLogger(getClass());
+    private transient String producerToString;
     private final Endpoint endpoint;
 
     public DefaultProducer(Endpoint endpoint) {
@@ -40,7 +41,10 @@ public abstract class DefaultProducer extends ServiceSupport implements
Producer
 
     @Override
     public String toString() {
-        return "Producer[" + URISupport.sanitizeUri(endpoint.getEndpointUri()) + "]";
+        if (producerToString == null) {
+            producerToString = "Producer[" + URISupport.sanitizeUri(endpoint.getEndpointUri())
+ "]";
+        }
+        return producerToString;
     }
 
     public Endpoint getEndpoint() {

http://git-wip-us.apache.org/repos/asf/camel/blob/c12fdebd/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
index 889d5b8..3588694 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SendProcessor extends ServiceSupport implements AsyncProcessor, Traceable, EndpointAware,
IdAware {
     protected static final Logger LOG = LoggerFactory.getLogger(SendProcessor.class);
+    protected transient String traceLabelToString;
     protected final CamelContext camelContext;
     protected final ExchangePattern pattern;
     protected ProducerCache producerCache;
@@ -100,7 +101,10 @@ public class SendProcessor extends ServiceSupport implements AsyncProcessor,
Tra
     }
 
     public String getTraceLabel() {
-        return URISupport.sanitizeUri(destination.getEndpointUri());
+        if (traceLabelToString == null) {
+            traceLabelToString = URISupport.sanitizeUri(destination.getEndpointUri());
+        }
+        return traceLabelToString;
     }
 
     @Override


Mime
View raw message