camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-10530: Fixed the build problem due missing command in jolokia
Date Fri, 06 Jan 2017 08:19:17 GMT
CAMEL-10530: Fixed the build problem due missing command in jolokia


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

Branch: refs/heads/master
Commit: 357d279a6aadb6dc7d9ec57b2d1bf78e7cff2f69
Parents: 6ac0cc1
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jan 6 09:19:09 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jan 6 09:19:09 2017 +0100

----------------------------------------------------------------------
 .../mbean/ManagedTransformerRegistry.java       |  3 --
 .../java/org/apache/camel/spi/Transformer.java  | 20 ++++-----
 .../jolokia/DefaultJolokiaCamelController.java  | 43 ++++++++++++++++++++
 3 files changed, 53 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/357d279a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTransformerRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTransformerRegistry.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTransformerRegistry.java
index e1373b7..a2611dd 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTransformerRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedTransformerRegistry.java
@@ -24,16 +24,13 @@ import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
 import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.api.management.mbean.CamelOpenMBeanTypes;
 import org.apache.camel.api.management.mbean.ManagedTransformerRegistryMBean;
-import org.apache.camel.spi.EndpointRegistry;
 import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.Transformer;
 import org.apache.camel.spi.TransformerRegistry;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.URISupport;
 
 /**
  * @version 

http://git-wip-us.apache.org/repos/asf/camel/blob/357d279a/camel-core/src/main/java/org/apache/camel/spi/Transformer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/Transformer.java b/camel-core/src/main/java/org/apache/camel/spi/Transformer.java
index da0b949..23439f5 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/Transformer.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/Transformer.java
@@ -20,20 +20,22 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.model.InputTypeDefinition;
+import org.apache.camel.model.OutputTypeDefinition;
 import org.apache.camel.support.ServiceSupport;
 
 /**
  * <a href="http://camel.apache.org/transformer.html">Transformer</a>
  * performs message transformation according to the declared data type.
- * There are two Exchange property indicates current message type, {@link Exchange.INPUT_TYPE}
- * holds input message type and {@link Exchange.OUTPUT_TYPE} holds output message type. If
the
+ * There are two Exchange property indicates current message type, {@link Exchange#INPUT_TYPE}
+ * holds input message type and {@link Exchange#OUTPUT_TYPE} holds output message type. If
the
  * input type and/or output type declared by {@link InputTypeDefinition}
  * and/or {@link OutputTypeDefinition} in the route definition is different from those property
  * at runtime, camel internal processor look for a Transformer which transforms from
  * the current message type to the expected message type.
  *  
- *  {@see InputTypeDefinition}
- *  {@see OutputTypeDefinition}
+ * @see InputTypeDefinition
+ * @see OutputTypeDefinition
  */
 public abstract class Transformer extends ServiceSupport implements CamelContextAware {
 
@@ -44,6 +46,7 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Perform data transformation with specified from/to type.
+     *
      * @param message message to apply transformation
      * @param from 'from' data type
      * @param to 'to' data type
@@ -52,7 +55,6 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Get a data model which is supported by this transformer.
-     * @return data model
      */
     public String getModel() {
         return model;
@@ -60,7 +62,6 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Get 'from' data type.
-     * @return 'from' data type
      */
     public DataType getFrom() {
         return from;
@@ -68,7 +69,6 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Get 'to' data type.
-     * @return 'to' data type
      */
     public DataType getTo() {
         return to;
@@ -76,8 +76,8 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Set data model.
+     *
      * @param model data model
-     * @return this Transformer instance
      */
     public Transformer setModel(String model) {
         this.model = model;
@@ -86,8 +86,8 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Set 'from' data type.
+     *
      * @param from 'from' data type
-     * @return this Transformer instance
      */
     public Transformer setFrom(String from) {
         this.from = new DataType(from);
@@ -96,8 +96,8 @@ public abstract class Transformer extends ServiceSupport implements CamelContext
 
     /**
      * Set 'to' data type.
+     *
      * @param to 'to' data type
-     * @return this Transformer instance
      */
     public Transformer setTo(String to) {
         this.to = new DataType(to);

http://git-wip-us.apache.org/repos/asf/camel/blob/357d279a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
index 5b02abb..c336d8c 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
@@ -759,6 +759,49 @@ public class DefaultJolokiaCamelController extends AbstractCamelController
imple
         return answer;
     }
 
+    @Override
+    public List<Map<String, String>> getTransformers(String camelContextName)
throws Exception {
+        if (jolokia == null) {
+            throw new IllegalStateException("Need to connect to remote jolokia first");
+        }
+
+        List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
+
+        ObjectName found = lookupCamelContext(camelContextName);
+        if (found != null) {
+            String pattern = String.format("%s:context=%s,type=services,name=DefaultTransformerRegistry",
found.getDomain(), found.getKeyProperty("context"));
+            ObjectName on = ObjectName.getInstance(pattern);
+
+            J4pExecResponse response = jolokia.execute(new J4pExecRequest(on, "listTransformers()"));
+            if (response != null) {
+                JSONObject data = response.getValue();
+                if (data != null) {
+                    for (Object obj : data.values()) {
+                        JSONObject data2 = (JSONObject) obj;
+                        JSONObject service = (JSONObject) data2.values().iterator().next();
+
+                        Map<String, String> row = new LinkedHashMap<String, String>();
+                        row.put("string", asString(service.get("string")));
+                        row.put("static", asString(service.get("static")));
+                        row.put("dynamic", asString(service.get("dynamic")));
+                        answer.add(row);
+                    }
+                }
+            }
+
+            // sort the list
+            Collections.sort(answer, new Comparator<Map<String, String>>() {
+                @Override
+                public int compare(Map<String, String> service1, Map<String, String>
service2) {
+                    String url1 = service1.get("string");
+                    String url2 = service2.get("string");
+                    return url1.compareTo(url2);
+                }
+            });
+        }
+        return answer;
+    }
+
     private static String asKey(String attributeKey) {
         char ch = Character.toLowerCase(attributeKey.charAt(0));
         return ch + attributeKey.substring(1);


Mime
View raw message