Repository: camel Updated Branches: refs/heads/master ebb24f54c -> 8f8e2f033
CAMEL-7790: Rest DSL - Add karaf commands to list the rest DSL as XML. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8f8e2f03 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8f8e2f03 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8f8e2f03 Branch: refs/heads/master Commit: 8f8e2f03392a15f9d50e6a70b2b1a22873c54f7e Parents: ebb24f5 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Sep 7 16:42:13 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Sep 7 16:42:13 2014 +0200 ---------------------------------------------------------------------- .../apache/camel/karaf/commands/RestShow.java | 49 ++++++++++++++++++++ .../OSGI-INF/blueprint/camel-commands.xml | 9 ++++ 2 files changed, 58 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8f8e2f03/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestShow.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestShow.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestShow.java new file mode 100644 index 0000000..44d9420 --- /dev/null +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestShow.java @@ -0,0 +1,49 @@ +/** + * 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 java.util.List; + +import org.apache.camel.model.ModelHelper; +import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.model.rest.RestsDefinition; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; + +/** + * Command to show the REST marshaled in XML. + */ +@Command(scope = "camel", name = "rest-show", description = "Display the Camel REST definition in XML.") +public class RestShow extends CamelCommandSupport { + + @Argument(index = 0, name = "context", description = "The Camel context name.", required = true, multiValued = false) + String context; + + public Object doExecute() throws Exception { + List<RestDefinition> rests = camelController.getRestDefinitions(context); + if (rests == null || rests.isEmpty()) { + System.out.print("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); + System.out.println(ModelHelper.dumpModelAsXml(def)); + return null; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/8f8e2f03/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 75ea340..0870a0a 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 @@ -203,6 +203,15 @@ <null/> </completers> </command> + <command name="camel/rest-show"> + <action class="org.apache.camel.karaf.commands.RestShow"> + <property name="camelController" ref="camelController"/> + </action> + <completers> + <ref component-id="camelContextCompleter"/> + <null/> + </completers> + </command> </command-bundle> <bean id="camelContextCompleter" class="org.apache.camel.karaf.commands.completers.CamelContextCompleter">