camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/6] camel git commit: Optimize getEndpointUri to avoid normalizing uri 2 times
Date Sat, 27 May 2017 12:47:23 GMT
Optimize getEndpointUri to avoid normalizing uri 2 times


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

Branch: refs/heads/master
Commit: be41ff6716b691b980e38faae51d48e076232e05
Parents: 55af2c3
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat May 27 12:14:17 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat May 27 12:14:17 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultCamelContext.java     | 13 ++++++++++++-
 .../main/java/org/apache/camel/impl/EndpointKey.java   |  8 ++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/be41ff67/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 7ed1d10..7ed6e84 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -657,7 +657,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
 
         Endpoint answer;
         String scheme = null;
-        EndpointKey key = getEndpointKey(uri);
+        // use optimized method to get the endpoint uri
+        EndpointKey key = getEndpointKeyPreNormalized(uri);
         answer = endpoints.get(key);
         if (answer == null) {
             try {
@@ -814,6 +815,16 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     /**
      * Gets the endpoint key to use for lookup or whe adding endpoints to the {@link DefaultEndpointRegistry}
      *
+     * @param uri the endpoint uri which is pre normalized
+     * @return the key
+     */
+    protected EndpointKey getEndpointKeyPreNormalized(String uri) {
+        return new EndpointKey(uri, true);
+    }
+
+    /**
+     * Gets the endpoint key to use for lookup or whe adding endpoints to the {@link DefaultEndpointRegistry}
+     *
      * @param uri      the endpoint uri
      * @param endpoint the endpoint
      * @return the key

http://git-wip-us.apache.org/repos/asf/camel/blob/be41ff67/camel-core/src/main/java/org/apache/camel/impl/EndpointKey.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/EndpointKey.java b/camel-core/src/main/java/org/apache/camel/impl/EndpointKey.java
index 9875491..f63477a 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/EndpointKey.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/EndpointKey.java
@@ -31,6 +31,14 @@ final class EndpointKey extends ValueHolder<String> {
         ObjectHelper.notEmpty(uri, "uri");
     }
 
+    /**
+     * Optimized when the uri is already normalized.
+     */
+    EndpointKey(String uri, boolean normalized) {
+        super(uri);
+        ObjectHelper.notEmpty(uri, "uri");
+    }
+
     @Override
     public String toString() {
         return get();


Mime
View raw message