camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/4] git commit: CAMEL-7620: Rest DSL. Enlist rest services in RestRegistry and JMX.
Date Wed, 30 Jul 2014 14:45:56 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/e30fd9f5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e30fd9f5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e30fd9f5

Branch: refs/heads/master
Commit: e30fd9f5717511e531edfb4660d619b5c46f62e7
Parents: 93ae72f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jul 30 16:22:14 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jul 30 16:22:14 2014 +0200

----------------------------------------------------------------------
 .../api/management/mbean/CamelOpenMBeanTypes.java    |  7 ++++---
 .../org/apache/camel/impl/DefaultRestRegistry.java   | 15 +++++++++++++++
 .../camel/management/mbean/ManagedRestRegistry.java  |  5 +++--
 .../main/java/org/apache/camel/spi/RestRegistry.java |  2 ++
 4 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e30fd9f5/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index d5736bc..6ef4b81 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -42,12 +42,13 @@ public final class CamelOpenMBeanTypes {
 
     public static TabularType listRestServicesTabularType() throws OpenDataException {
         CompositeType ct = listRestServicesCompositeType();
-        return new TabularType("listRestServices", "Lists all the rest services in the registry",
ct, new String[]{"url", "path", "verb", "consumes", "produces"});
+        return new TabularType("listRestServices", "Lists all the rest services in the registry",
ct, new String[]{"url", "path", "verb", "consumes", "produces", "state"});
     }
 
     public static CompositeType listRestServicesCompositeType() throws OpenDataException
{
-        return new CompositeType("types", "types", new String[]{"url", "path", "verb", "consumes",
"produces"},
-                new String[]{"Url", "Path", "Verb", "Consumes", "Produces"}, new OpenType[]{SimpleType.STRING,
SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING});
+        return new CompositeType("types", "types", new String[]{"url", "path", "verb", "consumes",
"produces", "state"},
+                new String[]{"Url", "Path", "Verb", "Consumes", "Produces", "State"},
+                new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
SimpleType.STRING, SimpleType.STRING});
     }
 
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e30fd9f5/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 612e9ed..6d8ea81 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
@@ -22,6 +22,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.Consumer;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.StatefulService;
 import org.apache.camel.StaticService;
 import org.apache.camel.spi.RestRegistry;
 
@@ -102,5 +104,18 @@ public class DefaultRestRegistry extends ServiceSupport implements StaticService
         public String getProduces() {
             return produces;
         }
+
+        public String getState() {
+            // must use String type to be sure remote JMX can read the attribute without
requiring Camel classes.
+            ServiceStatus status = null;
+            if (consumer instanceof StatefulService) {
+                status = ((StatefulService) consumer).getStatus();
+            }
+            // if no status exists then its stopped
+            if (status == null) {
+                status = ServiceStatus.Stopped;
+            }
+            return status.name();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e30fd9f5/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 99bf3f5..89c3030 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
@@ -64,8 +64,9 @@ public class ManagedRestRegistry extends ManagedService implements ManagedRestRe
                 String verb = entry.getVerb();
                 String consumes = entry.getConsumes();
                 String produces = entry.getProduces();
-                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "path",
"verb", "consumes", "produces"},
-                        new Object[]{url, path, verb, consumes, produces});
+                String state = entry.getState();
+                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "path",
"verb", "consumes", "produces", "state"},
+                        new Object[]{url, path, verb, consumes, produces, state});
                 answer.put(data);
             }
             return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/e30fd9f5/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 3509b6d..1b0d6af 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
@@ -36,6 +36,8 @@ public interface RestRegistry extends Service {
         String getConsumes();
 
         String getProduces();
+
+        String getState();
     }
 
     void addRestService(Consumer consumer, String url, String path, String verb, String consumes,
String produces);


Mime
View raw message