You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/12/10 17:32:11 UTC
[01/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
Repository: camel
Updated Branches:
refs/heads/master 41d085ecc -> 28165b61b
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/92516901
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/92516901
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/92516901
Branch: refs/heads/master
Commit: 925169017a1e575e63bb9de8fc258ac4c9c196bc
Parents: 41d085e
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 10:56:56 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 10:56:56 2014 +0100
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 53 ++++++++++++++------
.../org/apache/camel/util/ObjectHelper.java | 50 ++++++++++++++----
.../simple/SimpleOverrideMethodTest.java | 37 ++++++++++++++
3 files changed, 117 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/92516901/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 5b8804d..c386ae5 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -26,9 +26,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.camel.Attachments;
import org.apache.camel.Body;
@@ -296,18 +298,24 @@ public class BeanInfo {
LOG.trace("Introspecting class: {}", clazz);
- // if the class is not public then fallback and use interface methods if possible
- // this allow Camel to invoke private beans which implements interfaces
- List<Method> methods = Arrays.asList(clazz.getDeclaredMethods());
- if (!Modifier.isPublic(clazz.getModifiers())) {
- LOG.trace("Preferring interface methods as class: {} is not public accessible", clazz);
- List<Method> interfaceMethods = getInterfaceMethods(clazz);
-
- // still keep non-accessible class methods to provide more specific Exception if method is non-accessible
- interfaceMethods.addAll(methods);
- methods = interfaceMethods;
+ // favor interface methods, and then other declared methods which does not override the existing methods
+ List<Method> interfaceMethods = getInterfaceMethods(clazz);
+ Set<Method> overrides = new HashSet<Method>();
+ Set<Method> extraMethods = new HashSet<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+ for (Method target : extraMethods) {
+ for (Method interfaceMethod : interfaceMethods) {
+ if (ObjectHelper.isOverridingMethod(interfaceMethod, target, false)) {
+ overrides.add(target);
+ }
+ }
}
-
+ // remove all the overrides methods
+ extraMethods.removeAll(overrides);
+
+ List<Method> methods = interfaceMethods;
+ methods.addAll(extraMethods);
+
+ // now introspect the methods and filter non valid methods
for (Method method : methods) {
boolean valid = isValidMethod(clazz, method);
LOG.trace("Method: {} is valid: {}", method, valid);
@@ -383,6 +391,16 @@ public class BeanInfo {
public MethodInfo getMethodInfo(Method method) {
MethodInfo answer = methodMap.get(method);
if (answer == null) {
+ // maybe the method overrides, and the method map keeps info of the source override we can use
+ for (Method source : methodMap.keySet()) {
+ if (ObjectHelper.isOverridingMethod(source, method, false)) {
+ answer = methodMap.get(source);
+ break;
+ }
+ }
+ }
+
+ if (answer == null) {
// maybe the method is defined on a base class?
if (type != Object.class) {
Class<?> superclass = type.getSuperclass();
@@ -875,10 +893,17 @@ public class BeanInfo {
private static List<Method> getInterfaceMethods(Class<?> clazz) {
final List<Method> answer = new ArrayList<Method>();
- for (Class<?> interfaceClazz : clazz.getInterfaces()) {
- for (Method interfaceMethod : interfaceClazz.getDeclaredMethods()) {
- answer.add(interfaceMethod);
+
+ while (clazz != null && !clazz.equals(Object.class)) {
+ for (Class<?> interfaceClazz : clazz.getInterfaces()) {
+ for (Method interfaceMethod : interfaceClazz.getDeclaredMethods()) {
+ // must be a public method
+ if (Modifier.isPublic(interfaceMethod.getModifiers())) {
+ answer.add(interfaceMethod);
+ }
+ }
}
+ clazz = clazz.getSuperclass();
}
return answer;
http://git-wip-us.apache.org/repos/asf/camel/blob/92516901/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
index a468008..1e2ebfe 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -1094,22 +1094,54 @@ public final class ObjectHelper {
* @return <tt>true</tt> if it override, <tt>false</tt> otherwise
*/
public static boolean isOverridingMethod(Method source, Method target) {
- if (source.getName().equals(target.getName())
- && source.getReturnType().equals(target.getReturnType())
- && source.getParameterTypes().length == target.getParameterTypes().length) {
+ return isOverridingMethod(source, target, true);
+ }
- // test if parameter types is the same as well
- for (int i = 0; i < source.getParameterTypes().length; i++) {
+ /**
+ * Tests whether the target method overrides the source method.
+ * <p/>
+ * Tests whether they have the same name, return type, and parameter list.
+ *
+ * @param source the source method
+ * @param target the target method
+ * @param exact <tt>true</tt> if the override must be exact same types, <tt>false</tt> if the types should be assignable
+ * @return <tt>true</tt> if it override, <tt>false</tt> otherwise
+ */
+ public static boolean isOverridingMethod(Method source, Method target, boolean exact) {
+ if (!source.getName().equals(target.getName())) {
+ return false;
+ }
+
+ if (exact) {
+ if (!source.getReturnType().equals(target.getReturnType())) {
+ return false;
+ }
+ } else {
+ if (!source.getReturnType().isAssignableFrom(target.getReturnType())) {
+ return false;
+ }
+ }
+
+ // must have same number of parameter types
+ if (source.getParameterTypes().length != target.getParameterTypes().length) {
+ return false;
+ }
+
+ // test if parameter types is the same as well
+ for (int i = 0; i < source.getParameterTypes().length; i++) {
+ if (exact) {
if (!(source.getParameterTypes()[i].equals(target.getParameterTypes()[i]))) {
return false;
}
+ } else {
+ if (!(source.getParameterTypes()[i].isAssignableFrom(target.getParameterTypes()[i]))) {
+ return false;
+ }
}
-
- // the have same name, return type and parameter list, so its overriding
- return true;
}
- return false;
+ // the have same name, return type and parameter list, so its overriding
+ return true;
}
/**
http://git-wip-us.apache.org/repos/asf/camel/blob/92516901/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOverrideMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOverrideMethodTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOverrideMethodTest.java
new file mode 100644
index 0000000..46d6c06
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOverrideMethodTest.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.simple;
+
+import java.io.File;
+import java.nio.file.Path;
+
+import org.apache.camel.LanguageTestSupport;
+
+public class SimpleOverrideMethodTest extends LanguageTestSupport {
+
+ @Override
+ protected String getLanguageName() {
+ return "simple";
+ }
+
+ public void testOverrideMethod() throws Exception {
+ Path path = new File("target").toPath();
+ exchange.getIn().setBody(path);
+ assertExpression("${body.getFileName}", path.getFileName().toString());
+ }
+
+}
[04/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
Posted by da...@apache.org.
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9d5c459f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9d5c459f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9d5c459f
Branch: refs/heads/master
Commit: 9d5c459f6532945b5bde2c40927fb713a98b85d1
Parents: 46d464b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:00:55 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:00:55 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/camel/component/bean/BeanInfo.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9d5c459f/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 402e738..1c19945 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -306,17 +306,20 @@ public class BeanInfo {
} else {
LOG.trace("Preferring interface methods as class: {} is not public accessible", clazz);
methods = getInterfaceMethods(clazz);
+ // and then we must add its declared methods as well
+ List<Method> extraMethods = Arrays.asList(clazz.getDeclaredMethods());
+ methods.addAll(extraMethods);
}
- // it may have duplicate methods already in the declared list of methods, so lets remove those
+ // it may have duplicate methods already, even from declared or from interfaces + declared
Set<Method> overrides = new HashSet<Method>();
for (Method source : methods) {
for (Method target : methods) {
- // skip overselves
+ // skip ourselves
if (ObjectHelper.isOverridingMethod(source, target, true)) {
continue;
}
-
+ // skip duplicates which may be assign compatible (favor keep first added method when duplicate)
if (ObjectHelper.isOverridingMethod(source, target, false)) {
overrides.add(target);
}
@@ -325,6 +328,7 @@ public class BeanInfo {
methods.removeAll(overrides);
overrides.clear();
+ // if we are a public class, then add non duplicate interface classes also
if (Modifier.isPublic(clazz.getModifiers())) {
// add additional interface methods
List<Method> extraMethods = getInterfaceMethods(clazz);
[10/15] camel git commit: CAMEL-8041: Keep karaf camel commands help
up to date with the commands we have.
Posted by da...@apache.org.
CAMEL-8041: Keep karaf camel commands help up to date with the commands we have.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/da299a3b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/da299a3b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/da299a3b
Branch: refs/heads/master
Commit: da299a3b8c8b9eb048e4485387b4490d89065288
Parents: 050ee06
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 14:26:01 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 14:26:01 2014 +0100
----------------------------------------------------------------------
.../OSGI-INF/blueprint/camel-commands.xml | 36 --------------------
.../src/main/resources/OSGI-INF/bundle.info | 12 +++++--
2 files changed, 10 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/da299a3b/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml b/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
index d0496fb..02db00a 100644
--- a/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
+++ b/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
@@ -170,42 +170,6 @@
<null/>
</completers>
</command>
- <command name="camel/backlog-tracer-info">
- <action class="org.apache.camel.karaf.commands.BacklogTracerInfo">
- <property name="camelController" ref="camelController"/>
- </action>
- <completers>
- <ref component-id="camelContextCompleter"/>
- <null/>
- </completers>
- </command>
- <command name="camel/backlog-tracer-dump">
- <action class="org.apache.camel.karaf.commands.BacklogTracerDump">
- <property name="camelController" ref="camelController"/>
- </action>
- <completers>
- <ref component-id="camelContextCompleter"/>
- <null/>
- </completers>
- </command>
- <command name="camel/backlog-tracer-start">
- <action class="org.apache.camel.karaf.commands.BacklogTracerStart">
- <property name="camelController" ref="camelController"/>
- </action>
- <completers>
- <ref component-id="camelContextCompleter"/>
- <null/>
- </completers>
- </command>
- <command name="camel/backlog-tracer-stop">
- <action class="org.apache.camel.karaf.commands.BacklogTracerStop">
- <property name="camelController" ref="camelController"/>
- </action>
- <completers>
- <ref component-id="camelContextCompleter"/>
- <null/>
- </completers>
- </command>
<command name="camel/rest-registry-list">
<action class="org.apache.camel.karaf.commands.RestRegistryList">
<property name="camelController" ref="camelController"/>
http://git-wip-us.apache.org/repos/asf/camel/blob/da299a3b/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info b/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
index 15deb4d..b3df4af 100644
--- a/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
+++ b/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
@@ -10,20 +10,28 @@
This bundle provides the Karaf shell commands to manipulate and manage Camel Components.
The following commands are available:
+ \u001B[36mcamel:catalog-component-list\u001B[0m Lists all Camel components from the Camel catalog.
+ \u001B[36mcamel:catalog-label\u001B[0m Lists all Camel component labels from the Camel catalog.
+ \u001B[36mcamel:component-list\u001B[0m Lists all Camel components that are in use in Karaf.
\u001B[36mcamel:context-info\u001B[0m Display detailed information about a Camel context.
\u001B[36mcamel:context-list\u001B[0m Lists all Camel contexts.
+ \u001B[36mcamel:context-resume\u001B[0m Resumes a Camel context.
\u001B[36mcamel:context-start\u001B[0m Start a Camel context.
\u001B[36mcamel:context-stop\u001B[0m Stops a Camel context.
\u001B[36mcamel:context-suspend\u001B[0m Suspends a Camel context.
- \u001B[36mcamel:context-resume\u001B[0m Resumes a Camel context.
+ \u001B[36mcamel:endpoint-explain\u001B[0m Explain all Camel endpoints available in Camel Context deployed
+ \u001B[36mcamel:endpoint-list\u001B[0m List all Camel endpoints available in Camel Context deployed
+ \u001B[36mcamel:rest-registry-list\u001B[0m Lists all Camel REST services enlisted in the Rest Registry from all CamelContexts.
+ \u001B[36mcamel:rest-show\u001B[0m Display the Camel REST definition in XML..
\u001B[36mcamel:route-info\u001B[0m Display information about a Camel route.
\u001B[36mcamel:route-list\u001B[0m Lists the Camel routes.
+ \u001B[36mcamel:route-profile\u001B[0m Display profile information about Camel route(s).
+ \u001B[36mcamel:route-reset-stats\u001B[0m Reset performance stats on a route or group of routes.
\u001B[36mcamel:route-resume\u001B[0m Resume a Camel route.
\u001B[36mcamel:route-show\u001B[0m Display the Camel route definition in XML.
\u001B[36mcamel:route-start\u001B[0m Start a Camel route.
\u001B[36mcamel:route-stop\u001B[0m Stops a Camel route.
\u001B[36mcamel:route-suspend\u001B[0m Suspends a Camel route.
- \u001B[36mcamel:endpoint-list\u001B[0m List all Camel endpoints available in Camel Context deployed
\u001B[1mSEE ALSO\u001B[0m
\u001B[36mhttp://camel.apache.org/karaf.html\u001B[0m
\ No newline at end of file
[02/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
Posted by da...@apache.org.
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5bb673a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5bb673a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5bb673a
Branch: refs/heads/master
Commit: f5bb673aff138e42a0936d3997392a82512a86da
Parents: 9251690
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 11:05:38 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 11:05:38 2014 +0100
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 34 +++++++++++++-------
1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f5bb673a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index c386ae5..7f74407 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -298,21 +298,36 @@ public class BeanInfo {
LOG.trace("Introspecting class: {}", clazz);
- // favor interface methods, and then other declared methods which does not override the existing methods
- List<Method> interfaceMethods = getInterfaceMethods(clazz);
+ // favor declared methods, and then filter out duplicate interface methods
+ Set<Method> methods = new HashSet<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+
+ // it may have duplicate methods already in the declared list of methods, so lets remove those
Set<Method> overrides = new HashSet<Method>();
- Set<Method> extraMethods = new HashSet<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+ for (Method source : methods) {
+ for (Method target : methods) {
+ // skip overselves
+ if (ObjectHelper.isOverridingMethod(source, target, true)) {
+ continue;
+ }
+
+ if (ObjectHelper.isOverridingMethod(source, target, false)) {
+ overrides.add(target);
+ }
+ }
+ }
+ methods.removeAll(overrides);
+ overrides.clear();
+
+ List<Method> extraMethods = getInterfaceMethods(clazz);
for (Method target : extraMethods) {
- for (Method interfaceMethod : interfaceMethods) {
- if (ObjectHelper.isOverridingMethod(interfaceMethod, target, false)) {
+ for (Method source : methods) {
+ if (ObjectHelper.isOverridingMethod(source, target, false)) {
overrides.add(target);
}
}
}
// remove all the overrides methods
extraMethods.removeAll(overrides);
-
- List<Method> methods = interfaceMethods;
methods.addAll(extraMethods);
// now introspect the methods and filter non valid methods
@@ -897,10 +912,7 @@ public class BeanInfo {
while (clazz != null && !clazz.equals(Object.class)) {
for (Class<?> interfaceClazz : clazz.getInterfaces()) {
for (Method interfaceMethod : interfaceClazz.getDeclaredMethods()) {
- // must be a public method
- if (Modifier.isPublic(interfaceMethod.getModifiers())) {
- answer.add(interfaceMethod);
- }
+ answer.add(interfaceMethod);
}
}
clazz = clazz.getSuperclass();
[14/15] camel git commit: CAMEL-8044: Include state in xml dumps from
jmx api
Posted by da...@apache.org.
CAMEL-8044: Include state in xml dumps from jmx api
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e695d0da
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e695d0da
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e695d0da
Branch: refs/heads/master
Commit: e695d0da3194cf1584827cad8e2a13a5d887217f
Parents: f12797c
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 16:14:16 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 16:14:16 2014 +0100
----------------------------------------------------------------------
.../camel/management/mbean/ManagedCamelContext.java | 6 +++---
.../org/apache/camel/management/mbean/ManagedRoute.java | 8 +++-----
.../java/org/apache/camel/util/ProcessorStatDump.java | 11 +++++++++++
.../main/java/org/apache/camel/util/RouteStatDump.java | 11 +++++++++++
4 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e695d0da/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
index 69593eb..f3d2be5 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
@@ -370,7 +370,7 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti
public String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception {
StringBuilder sb = new StringBuilder();
- sb.append("<camelContextStat").append(String.format(" id=\"%s\"", getCamelId()));
+ sb.append("<camelContextStat").append(String.format(" id=\"%s\" state=\"%s\"", getCamelId(), getState()));
// use substring as we only want the attributes
String stat = dumpStatsAsXml(fullStats);
sb.append(" ").append(stat.substring(7, stat.length() - 2)).append(">\n");
@@ -397,7 +397,7 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti
sb.append(" <routeStats>\n");
for (ObjectName on : routes) {
ManagedRouteMBean route = MBeanServerInvocationHandler.newProxyInstance(server, on, ManagedRouteMBean.class, true);
- sb.append(" <routeStat").append(String.format(" id=\"%s\"", route.getRouteId()));
+ sb.append(" <routeStat").append(String.format(" id=\"%s\" state=\"%s\"", route.getRouteId(), route.getState()));
// use substring as we only want the attributes
stat = route.dumpStatsAsXml(fullStats);
sb.append(" ").append(stat.substring(7, stat.length() - 2)).append(">\n");
@@ -408,7 +408,7 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti
for (ManagedProcessorMBean processor : processors) {
// the processor must belong to this route
if (route.getRouteId().equals(processor.getRouteId())) {
- sb.append(" <processorStat").append(String.format(" id=\"%s\"", processor.getProcessorId()));
+ sb.append(" <processorStat").append(String.format(" id=\"%s\" index=\"%s\" state=\"%s\"", processor.getProcessorId(), processor.getIndex(), processor.getState()));
// use substring as we only want the attributes
sb.append(" ").append(processor.dumpStatsAsXml(fullStats).substring(7)).append("\n");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e695d0da/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
index 5b4a07a..a0bdfb1 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
@@ -303,7 +303,7 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList
// and now add the sorted list of processors to the xml output
for (ManagedProcessorMBean processor : mps) {
- sb.append(" <processorStat").append(String.format(" id=\"%s\" index=\"%s\"", processor.getProcessorId(), processor.getIndex()));
+ sb.append(" <processorStat").append(String.format(" id=\"%s\" index=\"%s\" state=\"%s\"", processor.getProcessorId(), processor.getIndex(), processor.getState()));
// do we have an accumulated time then append that
Long accTime = accumulatedTimes.get(processor.getProcessorId());
if (accTime != null) {
@@ -323,13 +323,11 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList
routeSelfTime = 0;
}
- int inflight = context.getInflightRepository().size(getRouteId());
-
StringBuilder answer = new StringBuilder();
- answer.append("<routeStat").append(String.format(" id=\"%s\"", route.getId()));
+ answer.append("<routeStat").append(String.format(" id=\"%s\"", route.getId())).append(String.format(" state=\"%s\"", getState()));
// use substring as we only want the attributes
String stat = dumpStatsAsXml(fullStats);
- answer.append(" exchangesInflight=\"").append(inflight).append("\"");
+ answer.append(" exchangesInflight=\"").append(getInflightExchanges()).append("\"");
answer.append(" selfProcessingTime=\"").append(routeSelfTime).append("\"");
answer.append(" ").append(stat.substring(7, stat.length() - 2)).append(">\n");
http://git-wip-us.apache.org/repos/asf/camel/blob/e695d0da/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java b/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
index b554476..000613e 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
@@ -35,6 +35,9 @@ public final class ProcessorStatDump {
private Integer index;
@XmlAttribute
+ private String state;
+
+ @XmlAttribute
private Long exchangesCompleted;
@XmlAttribute
@@ -110,6 +113,14 @@ public final class ProcessorStatDump {
this.index = index;
}
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
public Long getExchangesCompleted() {
return exchangesCompleted;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e695d0da/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
index 7b171e0..4a05413 100644
--- a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
+++ b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
@@ -36,6 +36,9 @@ public final class RouteStatDump {
private String id;
@XmlAttribute
+ private String state;
+
+ @XmlAttribute
private Long exchangesCompleted;
@XmlAttribute
@@ -112,6 +115,14 @@ public final class RouteStatDump {
this.id = id;
}
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
public Long getExchangesCompleted() {
return exchangesCompleted;
}
[12/15] camel git commit: CAMEL-8044: Camel commands should be more
reusable for remote JVMs
Posted by da...@apache.org.
CAMEL-8044: Camel commands should be more reusable for remote JVMs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fcc877ab
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fcc877ab
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fcc877ab
Branch: refs/heads/master
Commit: fcc877ab755b4ea738d03a8bde363a1fec816d14
Parents: 8390076
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 15:21:05 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 15:21:05 2014 +0100
----------------------------------------------------------------------
.../org/apache/camel/management/mbean/ManagedRoute.java | 3 +++
.../main/java/org/apache/camel/util/RouteStatDump.java | 11 +++++++++++
.../java/org/apache/camel/commands/RouteInfoCommand.java | 1 +
3 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fcc877ab/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
index 103d975..5b4a07a 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
@@ -323,10 +323,13 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList
routeSelfTime = 0;
}
+ int inflight = context.getInflightRepository().size(getRouteId());
+
StringBuilder answer = new StringBuilder();
answer.append("<routeStat").append(String.format(" id=\"%s\"", route.getId()));
// use substring as we only want the attributes
String stat = dumpStatsAsXml(fullStats);
+ answer.append(" exchangesInflight=\"").append(inflight).append("\"");
answer.append(" selfProcessingTime=\"").append(routeSelfTime).append("\"");
answer.append(" ").append(stat.substring(7, stat.length() - 2)).append(">\n");
http://git-wip-us.apache.org/repos/asf/camel/blob/fcc877ab/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
index f1d09b6..7b171e0 100644
--- a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
+++ b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
@@ -66,6 +66,9 @@ public final class RouteStatDump {
private Long meanProcessingTime;
@XmlAttribute
+ private Long exchangesInflight;
+
+ @XmlAttribute
private Long selfProcessingTime;
@XmlAttribute
@@ -197,6 +200,14 @@ public final class RouteStatDump {
this.selfProcessingTime = selfProcessingTime;
}
+ public Long getExchangesInflight() {
+ return exchangesInflight;
+ }
+
+ public void setExchangesInflight(Long exchangesInflight) {
+ this.exchangesInflight = exchangesInflight;
+ }
+
public String getResetTimestamp() {
return resetTimestamp;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fcc877ab/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
index eacfbb5..1c9acbc 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
@@ -64,6 +64,7 @@ public class RouteInfoCommand extends AbstractRouteCommand {
out.println(stringEscape.unescapeJava("\tExchanges Total: " + route.getExchangesCompleted() + route.getExchangesFailed()));
out.println(stringEscape.unescapeJava("\tExchanges Completed: " + route.getExchangesCompleted()));
out.println(stringEscape.unescapeJava("\tExchanges Failed: " + route.getExchangesFailed()));
+ out.println(stringEscape.unescapeJava("\tExchanges Inflight: " + route.getExchangesInflight()));
out.println(stringEscape.unescapeJava("\tMin Processing Time: " + route.getMinProcessingTime() + " ms"));
out.println(stringEscape.unescapeJava("\tMax Processing Time: " + route.getMaxProcessingTime() + " ms"));
out.println(stringEscape.unescapeJava("\tMean Processing Time: " + route.getMeanProcessingTime() + " ms"));
[08/15] camel git commit: CAMEL-8044: Camel commands should be more
reusable for remote JVMs
Posted by da...@apache.org.
CAMEL-8044: Camel commands should be more reusable for remote JVMs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0fe994b4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0fe994b4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0fe994b4
Branch: refs/heads/master
Commit: 0fe994b423314a0f8a4d10da272ba472e25d3403
Parents: 53b4e90
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:53:44 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:53:44 2014 +0100
----------------------------------------------------------------------
.../camel/commands/AbstractCamelController.java | 15 +++++++++++++--
.../org/apache/camel/commands/CamelController.java | 6 +++---
.../org/apache/camel/commands/RouteInfoCommand.java | 10 +++++-----
.../org/apache/camel/commands/RouteShowCommand.java | 8 +++-----
4 files changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0fe994b4/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
index 43a90c6..f0186ae 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
@@ -115,12 +115,23 @@ public abstract class AbstractCamelController implements CamelController {
}
@SuppressWarnings("deprecation")
- public RouteDefinition getRouteDefinition(String routeId, String camelContextName) {
+ public String getRouteModelAsXml(String routeId, String camelContextName) {
CamelContext context = this.getCamelContext(camelContextName);
if (context == null) {
return null;
}
- return context.getRouteDefinition(routeId);
+ RouteDefinition route = context.getRouteDefinition(routeId);
+ if (route == null) {
+ return null;
+ }
+
+ String xml;
+ try {
+ xml = ModelHelper.dumpModelAsXml(route);
+ } catch (JAXBException e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ }
+ return xml;
}
@SuppressWarnings("deprecation")
http://git-wip-us.apache.org/repos/asf/camel/blob/0fe994b4/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
index 18ea7f6..ddf4040 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
@@ -74,13 +74,13 @@ public interface CamelController {
Route getRoute(String routeId, String camelContextName);
/**
- * Return the definition of a route identified by a ID and a Camel context.
+ * Return the definition of a route as XML identified by a ID and a Camel context.
*
* @param routeId the route ID.
* @param camelContextName the Camel context.
- * @return the <code>RouteDefinition</code>.
+ * @return the route model as XML
*/
- RouteDefinition getRouteDefinition(String routeId, String camelContextName);
+ String getRouteModelAsXml(String routeId, String camelContextName);
/**
* Return the endpoints
http://git-wip-us.apache.org/repos/asf/camel/blob/0fe994b4/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
index 6a4e663..e648546 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
@@ -27,8 +27,6 @@ import javax.management.ObjectName;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
-import org.apache.camel.model.ModelHelper;
-import org.apache.camel.model.RouteDefinition;
import org.apache.camel.spi.ManagementAgent;
/**
@@ -136,9 +134,11 @@ public class RouteInfoCommand extends AbstractRouteCommand {
}
out.println("");
- out.println(stringEscape.unescapeJava("\u001B[1mDefinition\u001B[0m"));
- RouteDefinition definition = camelController.getRouteDefinition(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
- out.println(stringEscape.unescapeJava(ModelHelper.dumpModelAsXml(definition)));
+ String xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
+ if (xml != null) {
+ out.println(stringEscape.unescapeJava("\u001B[1mDefinition\u001B[0m"));
+ out.println(stringEscape.unescapeJava(xml));
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0fe994b4/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
index 8c150c3..af460a3 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
@@ -20,8 +20,6 @@ import java.io.PrintStream;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
-import org.apache.camel.model.ModelHelper;
-import org.apache.camel.model.RouteDefinition;
/**
* Command to show the route marshaled in XML.
@@ -34,10 +32,10 @@ public class RouteShowCommand extends AbstractRouteCommand {
@Override
public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- RouteDefinition routeDefinition = camelController.getRouteDefinition(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
- if (routeDefinition == null) {
+ String xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
+ if (xml == null) {
err.println("Definition of route " + camelRoute.getId() + " not found.");
}
- System.out.println(ModelHelper.dumpModelAsXml(routeDefinition));
+ System.out.println(xml);
}
}
[07/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
Posted by da...@apache.org.
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/53b4e90c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/53b4e90c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/53b4e90c
Branch: refs/heads/master
Commit: 53b4e90c535ad419a101129b02feccc6625b5043
Parents: 7a0f2e8
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:42:54 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:42:54 2014 +0100
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 29 ++++++++++++--------
1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/53b4e90c/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 1c19945..fb9c533 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -311,22 +311,27 @@ public class BeanInfo {
methods.addAll(extraMethods);
}
- // it may have duplicate methods already, even from declared or from interfaces + declared
Set<Method> overrides = new HashSet<Method>();
- for (Method source : methods) {
- for (Method target : methods) {
- // skip ourselves
- if (ObjectHelper.isOverridingMethod(source, target, true)) {
- continue;
- }
- // skip duplicates which may be assign compatible (favor keep first added method when duplicate)
- if (ObjectHelper.isOverridingMethod(source, target, false)) {
- overrides.add(target);
+
+ // do not remove duplicates form class from the Java itself as they have some "duplicates" we need
+ boolean javaClass = clazz.getName().startsWith("java.") || clazz.getName().startsWith("javax.");
+ if (!javaClass) {
+ // it may have duplicate methods already, even from declared or from interfaces + declared
+ for (Method source : methods) {
+ for (Method target : methods) {
+ // skip ourselves
+ if (ObjectHelper.isOverridingMethod(source, target, true)) {
+ continue;
+ }
+ // skip duplicates which may be assign compatible (favor keep first added method when duplicate)
+ if (ObjectHelper.isOverridingMethod(source, target, false)) {
+ overrides.add(target);
+ }
}
}
+ methods.removeAll(overrides);
+ overrides.clear();
}
- methods.removeAll(overrides);
- overrides.clear();
// if we are a public class, then add non duplicate interface classes also
if (Modifier.isPublic(clazz.getModifiers())) {
[11/15] camel git commit: CAMEL-8044: Camel commands should be more
reusable for remote JVMs
Posted by da...@apache.org.
CAMEL-8044: Camel commands should be more reusable for remote JVMs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/83900763
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/83900763
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/83900763
Branch: refs/heads/master
Commit: 83900763caecb384b8bc4c8a7be3d4fb5c852c7b
Parents: da299a3
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 15:08:09 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 15:08:09 2014 +0100
----------------------------------------------------------------------
.../camel/commands/AbstractCamelController.java | 44 +++++--
.../apache/camel/commands/CamelController.java | 20 +--
.../apache/camel/commands/RouteInfoCommand.java | 128 +++++++------------
.../camel/commands/RouteProfileCommand.java | 45 ++-----
4 files changed, 106 insertions(+), 131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/83900763/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
index f0186ae..0282e7a 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
@@ -20,12 +20,15 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
import javax.xml.bind.JAXBException;
import org.apache.camel.CamelContext;
@@ -38,6 +41,7 @@ import org.apache.camel.model.ModelHelper;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.rest.RestDefinition;
import org.apache.camel.model.rest.RestsDefinition;
+import org.apache.camel.spi.ManagementAgent;
import org.apache.camel.spi.RestRegistry;
import org.apache.camel.util.JsonSchemaHelper;
import org.apache.camel.util.ObjectHelper;
@@ -104,16 +108,6 @@ public abstract class AbstractCamelController implements CamelController {
return routes;
}
- public Route getRoute(String routeId, String camelContextName) {
- List<Route> routes = this.getRoutes(camelContextName);
- for (Route route : routes) {
- if (route.getId().equals(routeId)) {
- return route;
- }
- }
- return null;
- }
-
@SuppressWarnings("deprecation")
public String getRouteModelAsXml(String routeId, String camelContextName) {
CamelContext context = this.getCamelContext(camelContextName);
@@ -134,6 +128,36 @@ public abstract class AbstractCamelController implements CamelController {
return xml;
}
+ @Override
+ public String getRouteStatsAsXml(String routeId, String camelContextName, boolean fullStats, boolean includeProcessors) {
+ CamelContext context = this.getCamelContext(camelContextName);
+ if (context == null) {
+ return null;
+ }
+
+ try {
+ ManagementAgent agent = context.getManagementStrategy().getManagementAgent();
+ if (agent != null) {
+ MBeanServer mBeanServer = agent.getMBeanServer();
+ Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(agent.getMBeanObjectDomainName() + ":type=routes,name=\"" + routeId + "\",*"), null);
+ Iterator<ObjectName> iterator = set.iterator();
+ if (iterator.hasNext()) {
+ ObjectName routeMBean = iterator.next();
+
+ // the route must be part of the camel context
+ String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
+ if (camelId != null && camelId.equals(camelContextName)) {
+ String xml = (String) mBeanServer.invoke(routeMBean, "dumpRouteStatsAsXml", new Object[]{fullStats, includeProcessors}, new String[]{"boolean", "boolean"});
+ return xml;
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ }
+ return null;
+ }
+
@SuppressWarnings("deprecation")
public String getRestModelAsXml(String camelContextName) {
CamelContext context = this.getCamelContext(camelContextName);
http://git-wip-us.apache.org/repos/asf/camel/blob/83900763/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
index ddf4040..756caeb 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
@@ -65,15 +65,6 @@ public interface CamelController {
List<Route> getRoutes(String camelContextName, String filter);
/**
- * Return the route with the given route ID.
- *
- * @param routeId the route ID.
- * @param camelContextName the Camel context name.
- * @return the route.
- */
- Route getRoute(String routeId, String camelContextName);
-
- /**
* Return the definition of a route as XML identified by a ID and a Camel context.
*
* @param routeId the route ID.
@@ -83,6 +74,17 @@ public interface CamelController {
String getRouteModelAsXml(String routeId, String camelContextName);
/**
+ * Returns detailed route statistics as XML identified by a ID and a Camel context.
+ *
+ * @param routeId the route ID.
+ * @param camelContextName the Camel context.
+ * @param fullStats whether to include verbose stats
+ * @param includeProcessors whether to embed per processor stats from the route
+ * @return the route statistics as XML
+ */
+ String getRouteStatsAsXml(String routeId, String camelContextName, boolean fullStats, boolean includeProcessors);
+
+ /**
* Return the endpoints
*
* @param camelContextName the Camel context.
http://git-wip-us.apache.org/repos/asf/camel/blob/83900763/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
index e648546..eacfbb5 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
@@ -17,23 +17,23 @@
package org.apache.camel.commands;
import java.io.PrintStream;
+import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
-import org.apache.camel.spi.ManagementAgent;
+import org.apache.camel.util.RouteStatDump;
/**
* Command to display detailed information about a Camel route.
*/
public class RouteInfoCommand extends AbstractRouteCommand {
+ public static final String XML_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ public static final String OUTPUT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss";
private StringEscape stringEscape;
public RouteInfoCommand(String route, String context) {
@@ -52,89 +52,57 @@ public class RouteInfoCommand extends AbstractRouteCommand {
out.println(stringEscape.unescapeJava("\u001B[1m\u001B[33mCamel Route " + camelRoute.getId() + "\u001B[0m"));
out.println(stringEscape.unescapeJava("\tCamel Context: " + camelRoute.getRouteContext().getCamelContext().getName()));
out.println("");
- out.println(stringEscape.unescapeJava("\u001B[1mProperties\u001B[0m"));
- for (Map.Entry<String, Object> entry : camelRoute.getProperties().entrySet()) {
- out.println(stringEscape.unescapeJava("\t" + entry.getKey() + " = " + entry.getValue()));
- }
- out.println("");
out.println(stringEscape.unescapeJava("\u001B[1mStatistics\u001B[0m"));
- if (camelContext != null) {
- ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
- if (agent != null) {
- MBeanServer mBeanServer = agent.getMBeanServer();
- Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(agent.getMBeanObjectDomainName() + ":type=routes,name=\"" + camelRoute.getId() + "\",*"), null);
- Iterator<ObjectName> iterator = set.iterator();
- if (iterator.hasNext()) {
- ObjectName routeMBean = iterator.next();
- // the route must be part of the camel context
- String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
- if (camelId != null && camelId.equals(camelContext.getName())) {
- Integer inflightExchange = (Integer) mBeanServer.getAttribute(routeMBean, "InflightExchanges");
- out.println(stringEscape.unescapeJava("\tInflight Exchanges: " + inflightExchange));
- Long exchangesTotal = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesTotal");
- out.println(stringEscape.unescapeJava("\tExchanges Total: " + exchangesTotal));
- Long exchangesCompleted = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesCompleted");
- out.println(stringEscape.unescapeJava("\tExchanges Completed: " + exchangesCompleted));
- Long exchangesFailed = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesFailed");
- out.println(stringEscape.unescapeJava("\tExchanges Failed: " + exchangesFailed));
- Long minProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MinProcessingTime");
- out.println(stringEscape.unescapeJava("\tMin Processing Time: " + minProcessingTime + " ms"));
- Long maxProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MaxProcessingTime");
- out.println(stringEscape.unescapeJava("\tMax Processing Time: " + maxProcessingTime + " ms"));
- Long meanProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MeanProcessingTime");
- out.println(stringEscape.unescapeJava("\tMean Processing Time: " + meanProcessingTime + " ms"));
- Long totalProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "TotalProcessingTime");
- out.println(stringEscape.unescapeJava("\tTotal Processing Time: " + totalProcessingTime + " ms"));
- Long lastProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "LastProcessingTime");
- out.println(stringEscape.unescapeJava("\tLast Processing Time: " + lastProcessingTime + " ms"));
- Long deltaProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "DeltaProcessingTime");
- out.println(stringEscape.unescapeJava("\tDelta Processing Time: " + deltaProcessingTime + " ms"));
- String load01 = (String) mBeanServer.getAttribute(routeMBean, "Load01");
- String load05 = (String) mBeanServer.getAttribute(routeMBean, "Load05");
- String load15 = (String) mBeanServer.getAttribute(routeMBean, "Load15");
- out.println(stringEscape.unescapeJava("\tLoad Avg: " + load01 + ", " + load05 + ", " + load15));
+ String xml = camelController.getRouteStatsAsXml(camelRoute.getId(), camelContext.getName(), true, false);
+ if (xml != null) {
+ JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
+
+ out.println(stringEscape.unescapeJava("\tExchanges Total: " + route.getExchangesCompleted() + route.getExchangesFailed()));
+ out.println(stringEscape.unescapeJava("\tExchanges Completed: " + route.getExchangesCompleted()));
+ out.println(stringEscape.unescapeJava("\tExchanges Failed: " + route.getExchangesFailed()));
+ out.println(stringEscape.unescapeJava("\tMin Processing Time: " + route.getMinProcessingTime() + " ms"));
+ out.println(stringEscape.unescapeJava("\tMax Processing Time: " + route.getMaxProcessingTime() + " ms"));
+ out.println(stringEscape.unescapeJava("\tMean Processing Time: " + route.getMeanProcessingTime() + " ms"));
+ out.println(stringEscape.unescapeJava("\tTotal Processing Time: " + route.getTotalProcessingTime() + " ms"));
+ out.println(stringEscape.unescapeJava("\tLast Processing Time: " + route.getLastProcessingTime() + " ms"));
+ out.println(stringEscape.unescapeJava("\tDelta Processing Time: " + route.getDeltaProcessingTime() + " ms"));
- // Test for null to see if a any exchanges have been processed first to avoid NPE
- Object resetTimestampObj = mBeanServer.getAttribute(routeMBean, "ResetTimestamp");
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- if (resetTimestampObj == null) {
- // Print an empty value for scripting
- out.println(stringEscape.unescapeJava("\tReset Statistics Date:"));
- } else {
- Date firstExchangeTimestamp = (Date) resetTimestampObj;
- out.println(stringEscape.unescapeJava("\tReset Statistics Date: " + format.format(firstExchangeTimestamp)));
- }
+ // Test for null to see if a any exchanges have been processed first to avoid NPE
+ if (route.getResetTimestamp() == null) {
+ // Print an empty value for scripting
+ out.println(stringEscape.unescapeJava("\tReset Statistics Date:"));
+ } else {
+ Date date = new SimpleDateFormat(XML_TIMESTAMP_FORMAT).parse(route.getResetTimestamp());
+ String text = new SimpleDateFormat(OUTPUT_TIMESTAMP_FORMAT).format(date);
+ out.println(stringEscape.unescapeJava("\tReset Statistics Date: " + text));
+ }
- // Test for null to see if a any exchanges have been processed first to avoid NPE
- Object firstExchangeTimestampObj = mBeanServer.getAttribute(routeMBean, "FirstExchangeCompletedTimestamp");
- if (firstExchangeTimestampObj == null) {
- // Print an empty value for scripting
- out.println(stringEscape.unescapeJava("\tFirst Exchange Date:"));
- } else {
- Date firstExchangeTimestamp = (Date) firstExchangeTimestampObj;
- out.println(stringEscape.unescapeJava("\tFirst Exchange Date: " + format.format(firstExchangeTimestamp)));
- }
+ // Test for null to see if a any exchanges have been processed first to avoid NPE
+ if (route.getFirstExchangeCompletedTimestamp() == null) {
+ // Print an empty value for scripting
+ out.println(stringEscape.unescapeJava("\tFirst Exchange Date:"));
+ } else {
+ Date date = new SimpleDateFormat(XML_TIMESTAMP_FORMAT).parse(route.getFirstExchangeCompletedTimestamp());
+ String text = new SimpleDateFormat(OUTPUT_TIMESTAMP_FORMAT).format(date);
+ out.println(stringEscape.unescapeJava("\tFirst Exchange Date: " + text));
+ }
- // Again, check for null to avoid NPE
- Object lastExchangeCompletedTimestampObj = mBeanServer.getAttribute(routeMBean, "LastExchangeCompletedTimestamp");
- if (lastExchangeCompletedTimestampObj == null) {
- // Print an empty value for scripting
- out.println(stringEscape.unescapeJava("\tLast Exchange Completed Date:"));
- } else {
- Date lastExchangeCompletedTimestamp = (Date) lastExchangeCompletedTimestampObj;
- out.println(stringEscape.unescapeJava("\tLast Exchange Completed Date: " + format.format(lastExchangeCompletedTimestamp)));
- }
- }
- }
+ // Test for null to see if a any exchanges have been processed first to avoid NPE
+ if (route.getLastExchangeCompletedTimestamp() == null) {
+ // Print an empty value for scripting
+ out.println(stringEscape.unescapeJava("\tLast Exchange Date:"));
} else {
- out.println("");
- out.println(stringEscape.unescapeJava("\u001B[31mJMX Agent of Camel is not reachable. Maybe it has been disabled on the Camel context"));
- out.println(stringEscape.unescapeJava("In consequence, some statistics are not available.\u001B[0m"));
+ Date date = new SimpleDateFormat(XML_TIMESTAMP_FORMAT).parse(route.getLastExchangeCompletedTimestamp());
+ String text = new SimpleDateFormat(OUTPUT_TIMESTAMP_FORMAT).format(date);
+ out.println(stringEscape.unescapeJava("\tLast Exchange Date: " + text));
}
out.println("");
- String xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
+ xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
if (xml != null) {
out.println(stringEscape.unescapeJava("\u001B[1mDefinition\u001B[0m"));
out.println(stringEscape.unescapeJava(xml));
http://git-wip-us.apache.org/repos/asf/camel/blob/83900763/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
index cb746ec..c086122 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
@@ -18,15 +18,11 @@ package org.apache.camel.commands;
import java.io.PrintStream;
import java.io.StringReader;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.apache.camel.CamelContext;
import org.apache.camel.Route;
-import org.apache.camel.spi.ManagementAgent;
import org.apache.camel.util.ProcessorStatDump;
import org.apache.camel.util.RouteStatDump;
@@ -54,6 +50,7 @@ public class RouteProfileCommand extends AbstractRouteCommand {
@Override
public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
+
JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
@@ -65,36 +62,20 @@ public class RouteProfileCommand extends AbstractRouteCommand {
System.out.println(String.format(HEADER_FORMAT, "Id", "Count", "Last (ms)", "Delta (ms)", "Mean (ms)", "Min (ms)", "Max (ms)", "Total (ms)", "Self (ms)"));
}
- ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
- if (agent != null) {
- MBeanServer mBeanServer = agent.getMBeanServer();
- Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(agent.getMBeanObjectDomainName() + ":type=routes,name=\"" + camelRoute.getId() + "\",*"), null);
- for (ObjectName routeMBean : set) {
- // the route must be part of the camel context
- String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
- if (camelId != null && camelId.equals(camelContext.getName())) {
-
- String xml = (String) mBeanServer.invoke(routeMBean, "dumpRouteStatsAsXml", new Object[]{Boolean.FALSE, Boolean.TRUE}, new String[]{"boolean", "boolean"});
- RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
+ String xml = camelController.getRouteStatsAsXml(camelRoute.getId(), camelContext.getName(), true, true);
+ RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
- long count = route.getExchangesCompleted() + route.getExchangesFailed();
- System.out.println(String.format(OUTPUT_FORMAT, route.getId(), count, route.getLastProcessingTime(), route.getDeltaProcessingTime(),
- route.getMeanProcessingTime(), route.getMinProcessingTime(), route.getMaxProcessingTime(), route.getTotalProcessingTime(), route.getSelfProcessingTime()));
+ long count = route.getExchangesCompleted() + route.getExchangesFailed();
+ System.out.println(String.format(OUTPUT_FORMAT, route.getId(), count, route.getLastProcessingTime(), route.getDeltaProcessingTime(),
+ route.getMeanProcessingTime(), route.getMinProcessingTime(), route.getMaxProcessingTime(), route.getTotalProcessingTime(), route.getSelfProcessingTime()));
- for (ProcessorStatDump ps : route.getProcessorStats()) {
- // the self time is the total time of the processor itself
- long selfTime = ps.getTotalProcessingTime();
- count = ps.getExchangesCompleted() + ps.getExchangesFailed();
- // indent route id with 2 spaces
- System.out.println(String.format(OUTPUT_FORMAT, " " + ps.getId(), count, ps.getLastProcessingTime(), ps.getDeltaProcessingTime(),
- ps.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(), ps.getAccumulatedProcessingTime(), selfTime));
- }
- }
- }
- } else {
- System.out.println("");
- System.out.println(stringEscape.unescapeJava("\u001B[31mJMX Agent of Camel is not reachable. Maybe it has been disabled on the Camel context"));
- System.out.println(stringEscape.unescapeJava("In consequence, profile are not available.\u001B[0m"));
+ for (ProcessorStatDump ps : route.getProcessorStats()) {
+ // the self time is the total time of the processor itself
+ long selfTime = ps.getTotalProcessingTime();
+ count = ps.getExchangesCompleted() + ps.getExchangesFailed();
+ // indent route id with 2 spaces
+ System.out.println(String.format(OUTPUT_FORMAT, " " + ps.getId(), count, ps.getLastProcessingTime(), ps.getDeltaProcessingTime(),
+ ps.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(), ps.getAccumulatedProcessingTime(), selfTime));
}
// we want to group routes from the same context in the same table
[13/15] camel git commit: Disable geocoder test by default as it
requires online internet and working remote host.
Posted by da...@apache.org.
Disable geocoder test by default as it requires online internet and working remote host.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f12797ca
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f12797ca
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f12797ca
Branch: refs/heads/master
Commit: f12797ca311afbbccc71b5b81c787540adc8932b
Parents: fcc877a
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 15:44:21 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 15:44:21 2014 +0100
----------------------------------------------------------------------
components/camel-geocoder/pom.xml | 38 ++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f12797ca/components/camel-geocoder/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-geocoder/pom.xml b/components/camel-geocoder/pom.xml
index c702bcf..09f53c1 100644
--- a/components/camel-geocoder/pom.xml
+++ b/components/camel-geocoder/pom.xml
@@ -69,4 +69,42 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+ <excludes>
+ <!-- exclude all tests as they require online internet -->
+ <exclude>**/*Test.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>geo-test</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
[09/15] camel git commit: CAMEL-8140: Camel commands - Remove backlog
tracer commands
Posted by da...@apache.org.
CAMEL-8140: Camel commands - Remove backlog tracer commands
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/050ee060
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/050ee060
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/050ee060
Branch: refs/heads/master
Commit: 050ee0609923cccd41efcc3986b8208a0aefdb1e
Parents: 0fe994b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 14:25:40 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 14:25:40 2014 +0100
----------------------------------------------------------------------
.../commands/BacklogTracerDumpCommand.java | 121 -------------------
.../commands/BacklogTracerInfoCommand.java | 54 ---------
.../commands/BacklogTracerStartCommand.java | 62 ----------
.../commands/BacklogTracerStopCommand.java | 48 --------
.../camel/karaf/commands/BacklogTracerDump.java | 45 -------
.../camel/karaf/commands/BacklogTracerInfo.java | 34 ------
.../karaf/commands/BacklogTracerStart.java | 53 --------
.../camel/karaf/commands/BacklogTracerStop.java | 35 ------
8 files changed, 452 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerDumpCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerDumpCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerDumpCommand.java
deleted file mode 100644
index 65fe217..0000000
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerDumpCommand.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.commands;
-
-import java.io.PrintStream;
-import java.io.StringReader;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.api.management.mbean.BacklogTracerEventMessage;
-import org.apache.camel.processor.interceptor.BacklogTracer;
-import org.apache.camel.util.MessageDump;
-
-/**
- * Command to use the <a href="camel.apache.org/backlogtracer">Backlog Tracer</a>.
- */
-public class BacklogTracerDumpCommand extends AbstractContextCommand {
-
- private String pattern;
- private String format;
- private Integer bodySize;
-
- /**
- * @param context The name of the Camel context.
- * @param pattern To dump trace messages only for nodes or routes matching the given pattern (default is all)
- * @param format Format to use with the dump action (text or xml)
- * @param bodySize To limit the body size when using text format
- */
- public BacklogTracerDumpCommand(String context, String pattern, String format, Integer bodySize) {
- super(context);
- this.pattern = pattern;
- this.format = format;
- this.bodySize = bodySize;
- }
-
- @Override
- protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
- BacklogTracer backlogTracer = BacklogTracer.getBacklogTracer(camelContext);
- if (backlogTracer == null) {
- backlogTracer = (BacklogTracer) camelContext.getDefaultBacklogTracer();
- }
-
- if (format == null || "text".equals(format)) {
- JAXBContext context = JAXBContext.newInstance(MessageDump.class);
- Unmarshaller unmarshaller = context.createUnmarshaller();
- SimpleDateFormat sdf = new SimpleDateFormat(BacklogTracerEventMessage.TIMESTAMP_FORMAT);
-
- List<BacklogTracerEventMessage> events;
- if (pattern != null) {
- events = backlogTracer.dumpTracedMessages(pattern);
- } else {
- events = backlogTracer.dumpAllTracedMessages();
- }
- for (BacklogTracerEventMessage event : events) {
- MessageDump msg = (MessageDump) unmarshaller.unmarshal(new StringReader(event.getMessageAsXml()));
- String breadcrumb = getBreadcrumbId(msg.getHeaders());
-
- out.println("#" + event.getUid() + "\tTimestamp:\t" + sdf.format(event.getTimestamp()));
- if (breadcrumb != null) {
- out.println("Breadcrumb: " + breadcrumb);
- }
- out.println("ExchangeId: " + event.getExchangeId());
-
- if (event.getToNode() != null) {
- out.println("Route: " + event.getRouteId() + "\t--> " + event.getToNode());
- } else {
- out.println("Route: " + event.getRouteId());
- }
-
- String body = msg.getBody().getValue();
- if (bodySize != null && bodySize > 0) {
- if (body.length() > bodySize) {
- body = body.substring(0, bodySize);
- }
- }
- out.println(body);
- out.println("");
- }
- } else if ("xml".equals(format)) {
- if (pattern != null) {
- out.println("BacklogTracer messages:\n" + backlogTracer.dumpTracedMessages(pattern));
- } else {
- out.println("BacklogTracer messages:\n" + backlogTracer.dumpAllTracedMessagesAsXml());
- }
- return null;
- }
-
- return null;
- }
-
- private static String getBreadcrumbId(List<MessageDump.Header> headers) {
- if (headers == null || headers.isEmpty()) {
- return null;
- }
- for (MessageDump.Header header : headers) {
- if (header.getKey().equals(Exchange.BREADCRUMB_ID)) {
- return header.getValue();
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerInfoCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerInfoCommand.java
deleted file mode 100644
index 8ed5db1..0000000
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerInfoCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.commands;
-
-import java.io.PrintStream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.processor.interceptor.BacklogTracer;
-
-/**
- * Command to use the <a href="camel.apache.org/backlogtracer">Backlog Tracer</a>.
- */
-public class BacklogTracerInfoCommand extends AbstractContextCommand {
-
- public BacklogTracerInfoCommand(String context) {
- super(context);
- }
-
- @Override
- protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
- BacklogTracer backlogTracer = BacklogTracer.getBacklogTracer(camelContext);
- if (backlogTracer == null) {
- backlogTracer = (BacklogTracer) camelContext.getDefaultBacklogTracer();
- }
-
- out.println("BacklogTracer context:\t\t" + camelContext.getName());
- out.println("BacklogTracer enabled:\t\t" + backlogTracer.isEnabled());
- out.println("BacklogTracer pattern:\t\t" + (backlogTracer.getTracePattern() != null ? backlogTracer.getTracePattern() : ""));
- out.println("BacklogTracer filter:\t\t" + (backlogTracer.getTraceFilter() != null ? backlogTracer.getTraceFilter() : ""));
- out.println("BacklogTracer removeOnDump:\t" + backlogTracer.isRemoveOnDump());
- out.println("BacklogTracer backlogSize:\t" + backlogTracer.getBacklogSize());
- out.println("BacklogTracer tracerCount:\t" + backlogTracer.getTraceCounter());
- out.println("BacklogTracer body...");
- out.println("\tmaxChars:\t\t" + backlogTracer.getBodyMaxChars());
- out.println("\tincludeFiles:\t\t" + backlogTracer.isBodyIncludeFiles());
- out.println("\tincludeStreams:\t\t" + backlogTracer.isBodyIncludeStreams());
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStartCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStartCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStartCommand.java
deleted file mode 100644
index 9d9a66d..0000000
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStartCommand.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.commands;
-
-import java.io.PrintStream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.processor.interceptor.BacklogTracer;
-
-/**
- * Command to use the <a href="camel.apache.org/backlogtracer">Backlog Tracer</a>.
- */
-public class BacklogTracerStartCommand extends AbstractContextCommand {
-
- private String pattern;
- private String filter;
- private Integer backlogSize;
- private Boolean removeOnDump;
-
- public BacklogTracerStartCommand(String context, String pattern, String filter, Integer backlogSize, Boolean removeOnDump) {
- super(context);
- this.pattern = pattern;
- this.filter = filter;
- this.backlogSize = backlogSize;
- this.removeOnDump = removeOnDump;
- }
-
- @Override
- protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
- BacklogTracer backlogTracer = BacklogTracer.getBacklogTracer(camelContext);
- if (backlogTracer == null) {
- backlogTracer = (BacklogTracer) camelContext.getDefaultBacklogTracer();
- }
-
- backlogTracer.setEnabled(true);
- if (backlogSize != null) {
- backlogTracer.setBacklogSize(backlogSize);
- }
- if (removeOnDump != null) {
- backlogTracer.setRemoveOnDump(removeOnDump);
- }
- backlogTracer.setTracePattern(pattern);
- backlogTracer.setTraceFilter(filter);
-
- out.println("BacklogTracer started on " + camelContext.getName() + " with size: " + backlogTracer.getBacklogSize());
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStopCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStopCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStopCommand.java
deleted file mode 100644
index 3d53c82..0000000
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/BacklogTracerStopCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.commands;
-
-import java.io.PrintStream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.processor.interceptor.BacklogTracer;
-
-/**
- * Command to use the <a href="camel.apache.org/backlogtracer">Backlog Tracer</a>.
- */
-public class BacklogTracerStopCommand extends AbstractContextCommand {
-
- public BacklogTracerStopCommand(String context) {
- super(context);
- }
-
- @Override
- protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
- BacklogTracer backlogTracer = BacklogTracer.getBacklogTracer(camelContext);
- if (backlogTracer == null) {
- backlogTracer = (BacklogTracer) camelContext.getDefaultBacklogTracer();
- }
-
- // disable tracer and clear counter and the backlog queue
- backlogTracer.setEnabled(false);
- backlogTracer.resetTraceCounter();
- backlogTracer.clear();
- out.println("BacklogTracer stopped on " + camelContext.getName());
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerDump.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerDump.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerDump.java
deleted file mode 100644
index 1ecfaa4..0000000
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerDump.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.karaf.commands;
-
-import org.apache.camel.commands.BacklogTracerDumpCommand;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-
-@Command(scope = "camel", name = "backlog-tracer-dump", description = "Dumps traced messages from the Backlog tracer")
-public class BacklogTracerDump extends CamelCommandSupport {
-
- @Argument(index = 0, name = "context", description = "The name of the Camel context.", required = true, multiValued = false)
- String context;
-
- @Argument(index = 1, name = "pattern", description = "To dump trace messages only for nodes or routes matching the given pattern (default is all)", required = false, multiValued = false)
- String pattern;
-
- @Option(name = "--format", aliases = "-f", description = "Format to use with the dump action (text or xml)", required = false, multiValued = false, valueToShowInHelp = "text")
- String format;
-
- @Option(name = "--bodySize", aliases = "-bs", description = "To limit the body size when using text format", required = false, multiValued = false)
- Integer bodySize;
-
- @Override
- protected Object doExecute() throws Exception {
- BacklogTracerDumpCommand command = new BacklogTracerDumpCommand(context, pattern, format, bodySize);
- return command.execute(camelController, System.out, System.err);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerInfo.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerInfo.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerInfo.java
deleted file mode 100644
index 5ae7c08..0000000
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerInfo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.karaf.commands;
-
-import org.apache.camel.commands.BacklogTracerInfoCommand;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "camel", name = "backlog-tracer-info", description = "Displays the current status of the Backlog tracer")
-public class BacklogTracerInfo extends CamelCommandSupport {
-
- @Argument(index = 0, name = "context", description = "The name of the Camel context.", required = true, multiValued = false)
- String context;
-
- @Override
- protected Object doExecute() throws Exception {
- BacklogTracerInfoCommand command = new BacklogTracerInfoCommand(context);
- return command.execute(camelController, System.out, System.err);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStart.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStart.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStart.java
deleted file mode 100644
index 743e921..0000000
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStart.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.karaf.commands;
-
-import org.apache.camel.commands.BacklogTracerStartCommand;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-
-@Command(scope = "camel", name = "backlog-tracer-start", description = "Starts the Backlog tracer")
-public class BacklogTracerStart extends CamelCommandSupport {
-
- @Argument(index = 0, name = "context", description = "The name of the Camel context.",
- required = true, multiValued = false)
- String context;
-
- @Option(name = "--pattern", aliases = "-p", description = "To trace messages only for nodes or routes matching the given pattern (default is all)",
- required = false, multiValued = false)
- String pattern;
-
- @Option(name = "--filter", aliases = "-f", description = "To trace messages only for nodes or routes matching the given filter (using simple language by default)",
- required = false, multiValued = false)
- String filter;
-
- @Option(name = "--backlogSize", aliases = "-s", description = "Number of maximum traced messages in total to keep in the backlog (FIFO queue)",
- required = false, multiValued = false, valueToShowInHelp = "1000")
- Integer backlogSize;
-
- @Option(name = "--removeOnDump", aliases = "-r", description = "Whether to remove traced messages when dumping the messages",
- required = false, multiValued = false)
- Boolean removeOnDump;
-
- @Override
- protected Object doExecute() throws Exception {
- BacklogTracerStartCommand command = new BacklogTracerStartCommand(context, pattern, filter, backlogSize, removeOnDump);
- return command.execute(camelController, System.out, System.err);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/050ee060/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStop.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStop.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStop.java
deleted file mode 100644
index aa21f21..0000000
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/BacklogTracerStop.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.karaf.commands;
-
-import org.apache.camel.commands.BacklogTracerStopCommand;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-@Command(scope = "camel", name = "backlog-tracer-stop", description = "Stops the Backlog tracer")
-public class BacklogTracerStop extends CamelCommandSupport {
-
- @Argument(index = 0, name = "context", description = "The name of the Camel context.", required = true, multiValued = false)
- String context;
-
- @Override
- protected Object doExecute() throws Exception {
- BacklogTracerStopCommand command = new BacklogTracerStopCommand(context);
- return command.execute(camelController, System.out, System.err);
- }
-
-}
[15/15] camel git commit: CAMEL-8044: Camel commands should be more
reusable for remote JVMs
Posted by da...@apache.org.
CAMEL-8044: Camel commands should be more reusable for remote JVMs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/28165b61
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/28165b61
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/28165b61
Branch: refs/heads/master
Commit: 28165b61bdf666af0430420cca041c4edb932d09
Parents: e695d0d
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 16:20:41 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 16:31:34 2014 +0100
----------------------------------------------------------------------
.../camel/commands/AbstractCamelController.java | 26 ++++++++++++++++++
.../camel/commands/AbstractRouteCommand.java | 4 +--
.../apache/camel/commands/CamelController.java | 9 ++++--
.../apache/camel/commands/RouteInfoCommand.java | 11 ++++----
.../camel/commands/RouteProfileCommand.java | 7 ++---
.../camel/commands/RouteResetStatsCommand.java | 29 ++++----------------
.../camel/commands/RouteResumeCommand.java | 4 +--
.../apache/camel/commands/RouteShowCommand.java | 7 ++---
.../camel/commands/RouteStartCommand.java | 5 ++--
.../apache/camel/commands/RouteStopCommand.java | 5 ++--
.../camel/commands/RouteSuspendCommand.java | 5 ++--
.../camel/karaf/commands/RouteResetStats.java | 2 +-
12 files changed, 61 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
index 0282e7a..7cec798 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
@@ -108,6 +108,32 @@ public abstract class AbstractCamelController implements CamelController {
return routes;
}
+ public void resetRouteStats(String camelContextName) {
+ CamelContext context = this.getCamelContext(camelContextName);
+ if (context == null) {
+ return;
+ }
+
+ try {
+ ManagementAgent agent = context.getManagementStrategy().getManagementAgent();
+ if (agent != null) {
+ MBeanServer mBeanServer = agent.getMBeanServer();
+
+ // reset route mbeans
+ ObjectName query = ObjectName.getInstance(agent.getMBeanObjectDomainName() + ":type=routes,*");
+ Set<ObjectName> set = mBeanServer.queryNames(query, null);
+ for (ObjectName routeMBean : set) {
+ String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
+ if (camelId != null && camelId.equals(context.getName())) {
+ mBeanServer.invoke(routeMBean, "reset", new Object[]{true}, new String[]{"boolean"});
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ }
+ }
+
@SuppressWarnings("deprecation")
public String getRouteModelAsXml(String routeId, String camelContextName) {
CamelContext context = this.getCamelContext(camelContextName);
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractRouteCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractRouteCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractRouteCommand.java
index c9c75f7..fc1c83f 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractRouteCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractRouteCommand.java
@@ -59,7 +59,7 @@ public abstract class AbstractRouteCommand extends AbstractCamelCommand {
ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(camelContext.getApplicationContextClassLoader());
try {
- executeOnRoute(camelController, camelContext, camelRoute, out, err);
+ executeOnRoute(camelController, camelContext, camelRoute.getId(), out, err);
} finally {
Thread.currentThread().setContextClassLoader(oldClassloader);
}
@@ -68,7 +68,7 @@ public abstract class AbstractRouteCommand extends AbstractCamelCommand {
return null;
}
- public abstract void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception;
+ public abstract void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception;
/**
* To sort the routes.
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
index 756caeb..1f3759e 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
@@ -23,8 +23,6 @@ import java.util.Set;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.Route;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.rest.RestDefinition;
import org.apache.camel.spi.RestRegistry;
/**
@@ -65,6 +63,13 @@ public interface CamelController {
List<Route> getRoutes(String camelContextName, String filter);
/**
+ * Reset all the route stats for the given Camel context
+ *
+ * @param camelContextName the Camel context.
+ */
+ void resetRouteStats(String camelContextName);
+
+ /**
* Return the definition of a route as XML identified by a ID and a Camel context.
*
* @param routeId the route ID.
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
index 1c9acbc..982740d 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
@@ -24,7 +24,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
import org.apache.camel.util.RouteStatDump;
/**
@@ -48,13 +47,13 @@ public class RouteInfoCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- out.println(stringEscape.unescapeJava("\u001B[1m\u001B[33mCamel Route " + camelRoute.getId() + "\u001B[0m"));
- out.println(stringEscape.unescapeJava("\tCamel Context: " + camelRoute.getRouteContext().getCamelContext().getName()));
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ out.println(stringEscape.unescapeJava("\u001B[1m\u001B[33mCamel Route " + routeId + "\u001B[0m"));
+ out.println(stringEscape.unescapeJava("\tCamel Context: " + camelContext.getName()));
out.println("");
out.println(stringEscape.unescapeJava("\u001B[1mStatistics\u001B[0m"));
- String xml = camelController.getRouteStatsAsXml(camelRoute.getId(), camelContext.getName(), true, false);
+ String xml = camelController.getRouteStatsAsXml(routeId, camelContext.getName(), true, false);
if (xml != null) {
JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
@@ -103,7 +102,7 @@ public class RouteInfoCommand extends AbstractRouteCommand {
}
out.println("");
- xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
+ xml = camelController.getRouteModelAsXml(routeId, camelContext.getName());
if (xml != null) {
out.println(stringEscape.unescapeJava("\u001B[1mDefinition\u001B[0m"));
out.println(stringEscape.unescapeJava(xml));
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
index c086122..f17fab5 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteProfileCommand.java
@@ -22,7 +22,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
import org.apache.camel.util.ProcessorStatDump;
import org.apache.camel.util.RouteStatDump;
@@ -49,7 +48,7 @@ public class RouteProfileCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
@@ -58,11 +57,11 @@ public class RouteProfileCommand extends AbstractRouteCommand {
if (previousCamelContextName == null || !previousCamelContextName.equals(camelContext.getName())) {
System.out.println("");
System.out.println(stringEscape.unescapeJava("\u001B[1mProfile\u001B[0m"));
- System.out.println(stringEscape.unescapeJava("\tCamel Context: " + camelRoute.getRouteContext().getCamelContext().getName()));
+ System.out.println(stringEscape.unescapeJava("\tCamel Context: " + camelContext.getName()));
System.out.println(String.format(HEADER_FORMAT, "Id", "Count", "Last (ms)", "Delta (ms)", "Mean (ms)", "Min (ms)", "Max (ms)", "Total (ms)", "Self (ms)"));
}
- String xml = camelController.getRouteStatsAsXml(camelRoute.getId(), camelContext.getName(), true, true);
+ String xml = camelController.getRouteStatsAsXml(routeId, camelContext.getName(), true, true);
RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
long count = route.getExchangesCompleted() + route.getExchangesFailed();
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResetStatsCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResetStatsCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResetStatsCommand.java
index 52eba7e..cfc415c 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResetStatsCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResetStatsCommand.java
@@ -17,38 +17,21 @@
package org.apache.camel.commands;
import java.io.PrintStream;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
-import org.apache.camel.spi.ManagementAgent;
/**
* Command to reset route stats.
*/
-public class RouteResetStatsCommand extends AbstractRouteCommand {
+public class RouteResetStatsCommand extends AbstractContextCommand {
- public RouteResetStatsCommand(String route, String context) {
- super(route, context);
+ public RouteResetStatsCommand(String context) {
+ super(context);
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
- if (agent != null) {
- MBeanServer mBeanServer = agent.getMBeanServer();
-
- // reset route mbeans
- ObjectName query = ObjectName.getInstance(agent.getMBeanObjectDomainName() + ":type=routes,*");
- Set<ObjectName> set = mBeanServer.queryNames(query, null);
- for (ObjectName routeMBean : set) {
- String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
- if (camelId != null && camelId.equals(camelContext.getName())) {
- mBeanServer.invoke(routeMBean, "reset", new Object[]{true}, new String[]{"boolean"});
- }
- }
- }
+ protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
+ camelController.resetRouteStats(camelContext.getName());
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResumeCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResumeCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResumeCommand.java
index f7906e4..6876e81 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResumeCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteResumeCommand.java
@@ -31,7 +31,7 @@ public class RouteResumeCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- camelContext.resumeRoute(camelRoute.getId());
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ camelContext.resumeRoute(routeId);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
index af460a3..9379eb2 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteShowCommand.java
@@ -19,7 +19,6 @@ package org.apache.camel.commands;
import java.io.PrintStream;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
/**
* Command to show the route marshaled in XML.
@@ -31,10 +30,10 @@ public class RouteShowCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- String xml = camelController.getRouteModelAsXml(camelRoute.getId(), camelRoute.getRouteContext().getCamelContext().getName());
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ String xml = camelController.getRouteModelAsXml(routeId, camelContext.getName());
if (xml == null) {
- err.println("Definition of route " + camelRoute.getId() + " not found.");
+ err.println("Definition of route " + routeId + " not found.");
}
System.out.println(xml);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStartCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStartCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStartCommand.java
index 76ef065..b60fb5e 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStartCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStartCommand.java
@@ -19,7 +19,6 @@ package org.apache.camel.commands;
import java.io.PrintStream;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
/**
* Command to start a route.
@@ -31,7 +30,7 @@ public class RouteStartCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- camelContext.startRoute(camelRoute.getId());
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ camelContext.startRoute(routeId);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStopCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStopCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStopCommand.java
index 9a8600d..7412940 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStopCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteStopCommand.java
@@ -19,7 +19,6 @@ package org.apache.camel.commands;
import java.io.PrintStream;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
/**
* Command to stop a route.
@@ -31,7 +30,7 @@ public class RouteStopCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- camelContext.stopRoute(camelRoute.getId());
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ camelContext.stopRoute(routeId);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteSuspendCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteSuspendCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteSuspendCommand.java
index 0057a20..1f91c07 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteSuspendCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteSuspendCommand.java
@@ -19,7 +19,6 @@ package org.apache.camel.commands;
import java.io.PrintStream;
import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
/**
* Command to suspend a route.
@@ -31,7 +30,7 @@ public class RouteSuspendCommand extends AbstractRouteCommand {
}
@Override
- public void executeOnRoute(CamelController camelController, CamelContext camelContext, Route camelRoute, PrintStream out, PrintStream err) throws Exception {
- camelContext.suspendRoute(camelRoute.getId());
+ public void executeOnRoute(CamelController camelController, CamelContext camelContext, String routeId, PrintStream out, PrintStream err) throws Exception {
+ camelContext.suspendRoute(routeId);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/28165b61/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResetStats.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResetStats.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResetStats.java
index 1dbad3b..3832a8d 100644
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResetStats.java
+++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteResetStats.java
@@ -24,7 +24,7 @@ public class RouteResetStats extends AbstractRouteCommand {
@Override
protected Object doExecute() throws Exception {
- RouteResetStatsCommand command = new RouteResetStatsCommand(route, context);
+ RouteResetStatsCommand command = new RouteResetStatsCommand(context);
return command.execute(camelController, System.out, System.err);
}
[06/15] camel git commit: CAMEL-8044: Camel commands should be more
reusable for remote JVMs
Posted by da...@apache.org.
CAMEL-8044: Camel commands should be more reusable for remote JVMs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7a0f2e8e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7a0f2e8e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7a0f2e8e
Branch: refs/heads/master
Commit: 7a0f2e8eacd51c4788c723b7194176f2566e47e7
Parents: 1c323ae
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:33:50 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:33:50 2014 +0100
----------------------------------------------------------------------
.../camel/commands/AbstractCamelController.java | 22 ++++++++++++++++++--
.../apache/camel/commands/CamelController.java | 6 +++---
.../apache/camel/commands/RestShowCommand.java | 13 +++---------
3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7a0f2e8e/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
index bbe9b03..43a90c6 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractCamelController.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import javax.xml.bind.JAXBException;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
@@ -33,10 +34,13 @@ import org.apache.camel.Route;
import org.apache.camel.catalog.CamelComponentCatalog;
import org.apache.camel.catalog.DefaultCamelComponentCatalog;
import org.apache.camel.commands.internal.RegexUtil;
+import org.apache.camel.model.ModelHelper;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.rest.RestsDefinition;
import org.apache.camel.spi.RestRegistry;
import org.apache.camel.util.JsonSchemaHelper;
+import org.apache.camel.util.ObjectHelper;
/**
* Abstract {@link org.apache.camel.commands.CamelController} that implementators should extend.
@@ -120,12 +124,26 @@ public abstract class AbstractCamelController implements CamelController {
}
@SuppressWarnings("deprecation")
- public List<RestDefinition> getRestDefinitions(String camelContextName) {
+ public String getRestModelAsXml(String camelContextName) {
CamelContext context = this.getCamelContext(camelContextName);
if (context == null) {
return null;
}
- return context.getRestDefinitions();
+
+ List<RestDefinition> rests = context.getRestDefinitions();
+ if (rests == null || rests.isEmpty()) {
+ return null;
+ }
+ // use a rests definition to dump the rests
+ RestsDefinition def = new RestsDefinition();
+ def.setRests(rests);
+ String xml;
+ try {
+ xml = ModelHelper.dumpModelAsXml(def);
+ } catch (JAXBException e) {
+ throw ObjectHelper.wrapRuntimeCamelException(e);
+ }
+ return xml;
}
public List<Endpoint> getEndpoints(String camelContextName) {
http://git-wip-us.apache.org/repos/asf/camel/blob/7a0f2e8e/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
index f6d2b89..18ea7f6 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/CamelController.java
@@ -91,12 +91,12 @@ public interface CamelController {
List<Endpoint> getEndpoints(String camelContextName);
/**
- * Return the definition of the REST services for the given Camel context.
+ * Return the definition of the REST services as XML for the given Camel context.
*
* @param camelContextName the Camel context.
- * @return the <code>RouteDefinition</code>.
+ * @return the REST model as xml
*/
- List<RestDefinition> getRestDefinitions(String camelContextName);
+ String getRestModelAsXml(String camelContextName);
/**
* Return the REST services
http://git-wip-us.apache.org/repos/asf/camel/blob/7a0f2e8e/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestShowCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestShowCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestShowCommand.java
index 63f2310..328fa0d 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestShowCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestShowCommand.java
@@ -17,12 +17,8 @@
package org.apache.camel.commands;
import java.io.PrintStream;
-import java.util.List;
import org.apache.camel.CamelContext;
-import org.apache.camel.model.ModelHelper;
-import org.apache.camel.model.rest.RestDefinition;
-import org.apache.camel.model.rest.RestsDefinition;
/**
* Command to show the REST marshaled in XML.
@@ -35,15 +31,12 @@ public class RestShowCommand extends AbstractContextCommand {
@Override
protected Object performContextCommand(CamelController camelController, CamelContext camelContext, PrintStream out, PrintStream err) throws Exception {
- List<RestDefinition> rests = camelController.getRestDefinitions(context);
- if (rests == null || rests.isEmpty()) {
+ String xml = camelController.getRestModelAsXml(context);
+ if (xml == null) {
out.println("There are no REST services in CamelContext with name: " + context);
return null;
}
- // use a routes definition to dump the rests
- RestsDefinition def = new RestsDefinition();
- def.setRests(rests);
- out.println(ModelHelper.dumpModelAsXml(def));
+ out.println(xml);
return null;
}
}
[05/15] camel git commit: CAMEL-8044: Camel commands add more details
which has been added in camel-core
Posted by da...@apache.org.
CAMEL-8044: Camel commands add more details which has been added in camel-core
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1c323ae6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1c323ae6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1c323ae6
Branch: refs/heads/master
Commit: 1c323ae6dccb7e665a0472ea3e955ac907c4bd14
Parents: 9d5c459
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:27:15 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:27:15 2014 +0100
----------------------------------------------------------------------
.../camel/commands/RestRegistryListCommand.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1c323ae6/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java
index feda696..5977a03 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java
@@ -36,6 +36,7 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
private static final String URI_TEMPLATE_LABEL = "Uri Template";
private static final String METHOD_COLUMN_LABEL = "Method";
private static final String STATE_COLUMN_LABEL = "State";
+ private static final String ROUTE_COLUMN_LABEL = "Route";
private static final int DEFAULT_COLUMN_WIDTH_INCREMENT = 0;
private static final String DEFAULT_FIELD_PREAMBLE = " ";
@@ -71,8 +72,8 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
if (services.size() > 0) {
if (verbose) {
- out.println(String.format(headerFormat, CONTEXT_COLUMN_LABEL, URL_COLUMN_NAME, BASE_PATH_LABEL, URI_TEMPLATE_LABEL, METHOD_COLUMN_LABEL, STATE_COLUMN_LABEL));
- out.println(String.format(headerFormat, "-------", "---", "---------", "------------", "------", "-----"));
+ out.println(String.format(headerFormat, CONTEXT_COLUMN_LABEL, URL_COLUMN_NAME, BASE_PATH_LABEL, URI_TEMPLATE_LABEL, METHOD_COLUMN_LABEL, STATE_COLUMN_LABEL, ROUTE_COLUMN_LABEL));
+ out.println(String.format(headerFormat, "-------", "---", "---------", "------------", "------", "-----", "-----"));
} else {
out.println(String.format(headerFormat, CONTEXT_COLUMN_LABEL, BASE_PATH_LABEL, URI_TEMPLATE_LABEL, METHOD_COLUMN_LABEL, STATE_COLUMN_LABEL));
out.println(String.format(headerFormat, "-------", "---------", "------------", "------", "-----"));
@@ -96,8 +97,9 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
String uriTemplate = service.getUriTemplate() != null ? service.getUriTemplate() : "";
String method = service.getMethod();
String state = service.getState();
+ String route = service.getRouteId();
if (verbose) {
- out.println(String.format(rowFormat, contextId, uri, basePath, uriTemplate, method, state));
+ out.println(String.format(rowFormat, contextId, uri, basePath, uriTemplate, method, state, route));
} else {
out.println(String.format(rowFormat, contextId, basePath, uriTemplate, method, state));
}
@@ -115,6 +117,7 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
int maxUriTemplateLen = 0;
int maxMethodLen = 0;
int maxStatusLen = 0;
+ int maxRouteLen = 0;
for (Map.Entry<String, List<RestRegistry.RestService>> entry : services.entrySet()) {
String contextName = entry.getKey();
@@ -141,6 +144,9 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
String status = service.getState();
maxStatusLen = Math.max(maxStatusLen, status == null ? 0 : status.length());
+
+ String route = service.getRouteId();
+ maxRouteLen = Math.max(maxRouteLen, route == null ? 0 : route.length());
}
}
@@ -151,6 +157,7 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
retval.put(URI_TEMPLATE_LABEL, maxUriTemplateLen);
retval.put(METHOD_COLUMN_LABEL, maxMethodLen);
retval.put(STATE_COLUMN_LABEL, maxStatusLen);
+ retval.put(ROUTE_COLUMN_LABEL, maxRouteLen);
return retval;
}
@@ -175,11 +182,13 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
int uriTemplateLen = Math.min(columnWidths.get(URI_TEMPLATE_LABEL) + columnWidthIncrement, getMaxColumnWidth());
int methodLen = Math.min(columnWidths.get(METHOD_COLUMN_LABEL) + columnWidthIncrement, getMaxColumnWidth());
int statusLen = Math.min(columnWidths.get(STATE_COLUMN_LABEL) + columnWidthIncrement, getMaxColumnWidth());
+ int routeLen = Math.min(columnWidths.get(ROUTE_COLUMN_LABEL) + columnWidthIncrement, getMaxColumnWidth());
contextLen = Math.max(MIN_COLUMN_WIDTH, contextLen);
basePathLen = Math.max(MIN_COLUMN_WIDTH, basePathLen);
uriLen = Math.max(MIN_COLUMN_WIDTH, uriLen);
uriTemplateLen = Math.max(MIN_COLUMN_WIDTH, uriTemplateLen);
methodLen = Math.max(MIN_COLUMN_WIDTH, methodLen);
+ routeLen = Math.max(MIN_COLUMN_WIDTH, routeLen);
// last row does not have min width
@@ -192,6 +201,7 @@ public class RestRegistryListCommand extends AbstractCamelCommand {
retval.append(fieldPreamble).append("%-").append(uriTemplateLen).append('.').append(uriTemplateLen).append('s').append(fieldPostamble).append(' ');
retval.append(fieldPreamble).append("%-").append(methodLen).append('.').append(methodLen).append('s').append(fieldPostamble).append(' ');
retval.append(fieldPreamble).append("%-").append(statusLen).append('.').append(statusLen).append('s').append(fieldPostamble).append(' ');
+ retval.append(fieldPreamble).append("%-").append(routeLen).append('.').append(routeLen).append('s').append(fieldPostamble).append(' ');
return retval.toString();
}
[03/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
Posted by da...@apache.org.
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/46d464b4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/46d464b4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/46d464b4
Branch: refs/heads/master
Commit: 46d464b4619ad398259d4ce577bffbebfdfbb72d
Parents: f5bb673
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 11:19:23 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 11:19:23 2014 +0100
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 28 +++++++++++++-------
1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/46d464b4/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 7f74407..402e738 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -299,7 +299,14 @@ public class BeanInfo {
LOG.trace("Introspecting class: {}", clazz);
// favor declared methods, and then filter out duplicate interface methods
- Set<Method> methods = new HashSet<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+ List<Method> methods;
+ if (Modifier.isPublic(clazz.getModifiers())) {
+ LOG.trace("Preferring class methods as class: {} is public accessible", clazz);
+ methods = new ArrayList<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+ } else {
+ LOG.trace("Preferring interface methods as class: {} is not public accessible", clazz);
+ methods = getInterfaceMethods(clazz);
+ }
// it may have duplicate methods already in the declared list of methods, so lets remove those
Set<Method> overrides = new HashSet<Method>();
@@ -318,17 +325,20 @@ public class BeanInfo {
methods.removeAll(overrides);
overrides.clear();
- List<Method> extraMethods = getInterfaceMethods(clazz);
- for (Method target : extraMethods) {
- for (Method source : methods) {
- if (ObjectHelper.isOverridingMethod(source, target, false)) {
- overrides.add(target);
+ if (Modifier.isPublic(clazz.getModifiers())) {
+ // add additional interface methods
+ List<Method> extraMethods = getInterfaceMethods(clazz);
+ for (Method target : extraMethods) {
+ for (Method source : methods) {
+ if (ObjectHelper.isOverridingMethod(source, target, false)) {
+ overrides.add(target);
+ }
}
}
+ // remove all the overrides methods
+ extraMethods.removeAll(overrides);
+ methods.addAll(extraMethods);
}
- // remove all the overrides methods
- extraMethods.removeAll(overrides);
- methods.addAll(extraMethods);
// now introspect the methods and filter non valid methods
for (Method method : methods) {