camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/7] camel git commit: CAMEL-7999: More components include documentation
Date Fri, 02 Jan 2015 15:28:38 GMT
CAMEL-7999: More components include documentation


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

Branch: refs/heads/master
Commit: b1f9caced52f5b52b3265e79b972e762bfd56bcc
Parents: 4d762f5
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jan 2 16:08:33 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jan 2 16:10:34 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  |  2 ++
 .../guava/eventbus/GuavaEventBusComponent.java  | 19 +++++++-------
 .../guava/eventbus/GuavaEventBusEndpoint.java   | 26 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b1f9cace/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 89d66b8..fb42e4e 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
@@ -1338,6 +1338,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
         } else if ("gauth".equals(componentName) || "ghttp".equals(componentName) || "glogin".equals(componentName)
                 || "gmail".equals(componentName) || "gtask".equals(componentName)) {
             return "gae/" + componentName.substring(1);
+        } else if ("guava-eventbus".equals(componentName)) {
+            return "guava/eventbus";
         } else if ("atmosphere-websocket".equals(componentName)) {
             return "atmosphere/websocket";
         } else if ("netty-http".equals(componentName)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/b1f9cace/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusComponent.java
b/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusComponent.java
index c124344..1a08a88 100644
--- a/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusComponent.java
+++ b/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusComponent.java
@@ -20,27 +20,28 @@ import java.util.Map;
 
 import com.google.common.eventbus.EventBus;
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.impl.UriEndpointComponent;
 
 /**
  * Camel component for Guava EventBus
  * (http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/eventbus/EventBus.html).
Supports both
  * producer and consumer endpoints.
  */
-public class GuavaEventBusComponent extends DefaultComponent {
+public class GuavaEventBusComponent extends UriEndpointComponent {
 
     private EventBus eventBus;
     private Class<?> listenerInterface;
 
+    public GuavaEventBusComponent() {
+        super(GuavaEventBusEndpoint.class);
+    }
+
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        EventBus resolvedEventBus = eventBus;
-        if (resolvedEventBus == null) {
-            resolvedEventBus = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining,
EventBus.class);
-        }
-
-        return new GuavaEventBusEndpoint(uri, this, resolvedEventBus, listenerInterface);
+        GuavaEventBusEndpoint answer = new GuavaEventBusEndpoint(uri, this, eventBus, listenerInterface);
+        answer.setEventBusRef(remaining);
+        setProperties(answer, parameters);
+        return answer;
     }
 
     public EventBus getEventBus() {

http://git-wip-us.apache.org/repos/asf/camel/blob/b1f9cace/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusEndpoint.java
b/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusEndpoint.java
index f806f79..d5f4295 100644
--- a/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusEndpoint.java
+++ b/components/camel-guava-eventbus/src/main/java/org/apache/camel/component/guava/eventbus/GuavaEventBusEndpoint.java
@@ -24,15 +24,25 @@ import org.apache.camel.MultipleConsumersSupport;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.CamelContextHelper;
 
 /**
  * Guava EventBus (http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/eventbus/EventBus.html)
  * endpoint. Can create both producer and consumer ends of the route.
  */
+@UriEndpoint(scheme = "guava-eventbus", consumerClass = GuavaEventBusConsumer.class, label
= "eventbus")
 public class GuavaEventBusEndpoint extends DefaultEndpoint implements MultipleConsumersSupport
{
 
     private EventBus eventBus;
+
+    @UriPath
+    private String eventBusRef;
+    @UriParam
     private Class<?> eventClass;
+    @UriParam
     private Class<?> listenerInterface;
 
     public GuavaEventBusEndpoint(String endpointUri, Component component, EventBus eventBus,
Class<?> listenerInterface) {
@@ -69,6 +79,14 @@ public class GuavaEventBusEndpoint extends DefaultEndpoint implements MultipleCo
         return exchange;
     }
 
+    public String getEventBusRef() {
+        return eventBusRef;
+    }
+
+    public void setEventBusRef(String eventBusRef) {
+        this.eventBusRef = eventBusRef;
+    }
+
     public EventBus getEventBus() {
         return eventBus;
     }
@@ -93,4 +111,12 @@ public class GuavaEventBusEndpoint extends DefaultEndpoint implements
MultipleCo
         this.listenerInterface = listenerInterface;
     }
 
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        if (eventBusRef != null && eventBus == null) {
+            eventBus = CamelContextHelper.mandatoryLookup(getCamelContext(), eventBusRef,
EventBus.class);
+        }
+    }
 }


Mime
View raw message