camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-7620: Rest DSL. Enlist rest services in RestRegistry and JMX.
Date Tue, 05 Aug 2014 09:18:48 GMT
CAMEL-7620: Rest DSL. Enlist rest services in RestRegistry and JMX.


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

Branch: refs/heads/master
Commit: cafaa830d8607004fc83f666ada93f4f7b99e8cc
Parents: 3b0b549
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Aug 5 10:02:21 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Aug 5 11:18:26 2014 +0200

----------------------------------------------------------------------
 .../camel/component/rest/RestEndpoint.java      |  4 +-
 .../apache/camel/impl/DefaultRestRegistry.java  |  8 +--
 .../management/mbean/ManagedRestRegistry.java   |  4 +-
 .../java/org/apache/camel/spi/RestRegistry.java | 57 ++++++++++++++++++--
 4 files changed, 62 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cafaa830/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index 10d366c..d908452 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -155,7 +155,9 @@ public class RestEndpoint extends DefaultEndpoint {
             configureConsumer(consumer);
 
             // add to rest registry so we can keep track of them, we will remove from the
registry when the consumer is removed
-            getCamelContext().getRestRegistry().addRestService(consumer, null, getPath(),
getVerb(), getConsumes(), getProduces());
+            // TODO: need to get the absolute url of the service
+            // TODO: need to be able to unregister from the registry
+            getCamelContext().getRestRegistry().addRestService(consumer, null, getVerb(),
getPath(), getConsumes(), getProduces());
 
             return consumer;
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/cafaa830/camel-core/src/main/java/org/apache/camel/impl/DefaultRestRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRestRegistry.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultRestRegistry.java
index 6d8ea81..6c4e994 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRestRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRestRegistry.java
@@ -31,8 +31,8 @@ public class DefaultRestRegistry extends ServiceSupport implements StaticService
 
     private final Map<Consumer, RestService> registry = new LinkedHashMap<Consumer,
RestService>();
 
-    public void addRestService(Consumer consumer, String url, String path, String verb, String
consumes, String produces) {
-        RestServiceEntry entry = new RestServiceEntry(consumer, url, path, verb, consumes,
produces);
+    public void addRestService(Consumer consumer, String url, String method, String uriTemplate,
String consumes, String produces) {
+        RestServiceEntry entry = new RestServiceEntry(consumer, url, uriTemplate, method,
consumes, produces);
         registry.put(consumer, entry);
     }
 
@@ -89,11 +89,11 @@ public class DefaultRestRegistry extends ServiceSupport implements StaticService
             return url;
         }
 
-        public String getPath() {
+        public String getUriTemplate() {
             return path;
         }
 
-        public String getVerb() {
+        public String getMethod() {
             return verb;
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/cafaa830/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRestRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRestRegistry.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRestRegistry.java
index 89c3030..b5877e4 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRestRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRestRegistry.java
@@ -60,8 +60,8 @@ public class ManagedRestRegistry extends ManagedService implements ManagedRestRe
             for (RestRegistry.RestService entry : services) {
                 CompositeType ct = CamelOpenMBeanTypes.listRestServicesCompositeType();
                 String url = entry.getUrl();
-                String path = entry.getPath();
-                String verb = entry.getVerb();
+                String path = entry.getUriTemplate();
+                String verb = entry.getMethod();
                 String consumes = entry.getConsumes();
                 String produces = entry.getProduces();
                 String state = entry.getState();

http://git-wip-us.apache.org/repos/asf/camel/blob/cafaa830/camel-core/src/main/java/org/apache/camel/spi/RestRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestRegistry.java b/camel-core/src/main/java/org/apache/camel/spi/RestRegistry.java
index 1b0d6af..db06295 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/RestRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/RestRegistry.java
@@ -21,29 +21,78 @@ import java.util.List;
 import org.apache.camel.Consumer;
 import org.apache.camel.Service;
 
+/**
+ * A registry of all REST services running within the {@link org.apache.camel.CamelContext}
which have been defined and created
+ * using the <a href="http://camel.apache.org/rest-dsl">Rest DSL</a>.
+ */
 public interface RestRegistry extends Service {
 
+    /**
+     * Details about the REST service
+     */
     interface RestService {
 
+        /**
+         * Gets the consumer of the REST service
+         */
         Consumer getConsumer();
 
+        /**
+         * Gets the state of the REST service (started, stopped, etc)
+         */
+        String getState();
+
+        /**
+         * Gets the absolute url to the REST service
+         */
         String getUrl();
 
-        String getPath();
+        /**
+         * Gets the uri template (context path)
+         */
+        String getUriTemplate();
 
-        String getVerb();
+        /**
+         * Gets the HTTP method (GET, POST, PUT etc)
+         */
+        String getMethod();
 
+        /**
+         * Optional details about what media-types the REST service accepts
+         */
         String getConsumes();
 
+        /**
+         * Optional details about what media-types the REST service returns
+         */
         String getProduces();
 
-        String getState();
     }
 
-    void addRestService(Consumer consumer, String url, String path, String verb, String consumes,
String produces);
+    /**
+     * Adds a new REST service to the registry.
+     *
+     * @param consumer    the consumer
+     * @param url         the absolute url of the REST service
+     * @param method      the HTTP method
+     * @param uriTemplate the uri template (context-path)
+     * @param consumes    optional details about what media-types the REST service accepts
+     * @param produces    optional details about what media-types the REST service returns
+     */
+    void addRestService(Consumer consumer, String url, String method, String uriTemplate,
String consumes, String produces);
 
+    /**
+     * Removes the REST service from the registry
+     *
+     * @param consumer  the consumer
+     */
     void removeRestService(Consumer consumer);
 
+    /**
+     * List all REST services from this registry.
+     *
+     * @return all the REST services
+     */
     List<RestService> listAllRestServices();
 
     /**


Mime
View raw message