You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/12/02 11:36:16 UTC

svn commit: r722415 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java

Author: jstrachan
Date: Tue Dec  2 02:36:15 2008
New Revision: 722415

URL: http://svn.apache.org/viewvc?rev=722415&view=rev
Log:
minor refactor of RefComponent so it can be used as a base class for RegistryComponent. See http://www.nabble.com/Registry-Repository-support-in-CAMEL-td20774062s22882.html

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java?rev=722415&r1=722414&r2=722415&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/ref/RefComponent.java Tue Dec  2 02:36:15 2008
@@ -29,7 +29,23 @@
 public class RefComponent extends DefaultComponent {
 
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
-        String name = uri.substring("ref:".length());
+        // lets remove the scheme from the URI
+        int index = uri.indexOf(":");
+        String name = uri;
+        if (index >= 0) {
+            name = uri.substring(index + 1);
+        }
+        return lookupEndpoint(name, parameters);
+    }
+
+    /**
+     * Looks up an endpoint for a given name.
+     *
+     * Derived classes could use this name as a logical name and look it up on some registry.
+     *
+     * The default implementation will look up the name in the registry of the {@link #getCamelContext()} property
+     */
+    protected Endpoint lookupEndpoint(String name, Map parameters) {
         return getCamelContext().getRegistry().lookup(name, Endpoint.class);
     }
 }