CAMEL-11756: remove camel-commands-spring-boot as its not supported in Spring Boot 2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/413e070a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/413e070a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/413e070a Branch: refs/heads/boot2 Commit: 413e070a54711c848c7b76567cb6a0b8086b0894 Parents: a5d6ad7 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Sep 10 12:04:23 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Sep 10 12:04:23 2017 +0200 ---------------------------------------------------------------------- apache-camel/pom.xml | 4 - .../src/main/descriptors/common-bin.xml | 1 - parent/pom.xml | 5 - .../commands/commands-spring-boot/README.md | 34 --- platforms/commands/commands-spring-boot/pom.xml | 52 ---- .../commands/crsh/ArgumentCamelContext.java | 31 --- .../commands/crsh/ArgumentRouteID.java | 31 --- .../commands/crsh/CamelCommandsFacade.java | 132 ---------- .../commands/crsh/CamelCommandsPlugin.java | 56 ----- .../commands/crsh/CamelCompleter.java | 71 ------ .../commands/crsh/CamelControllerImpl.java | 83 ------ .../commands/crsh/NoopStringEscape.java | 34 --- .../springboot/commands/crsh/OutputBuffer.java | 51 ---- .../services/org.crsh.plugin.CRaSHPlugin | 17 -- .../resources/crash/commands/camel/camel.groovy | 251 ------------------- platforms/commands/pom.xml | 1 - 16 files changed, 854 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 64b68d5..4f3e63f 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -2445,10 +2445,6 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-spring-boot</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> <artifactId>camel-route-parser</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/apache-camel/src/main/descriptors/common-bin.xml ---------------------------------------------------------------------- diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index efc78bf..b9a533a 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -314,7 +314,6 @@ <include>org.apache.camel:camel-catalog-rest-app</include> <include>org.apache.camel:camel-commands-core</include> <include>org.apache.camel:camel-commands-jolokia</include> - <include>org.apache.camel:camel-commands-spring-boot</include> <include>org.apache.camel.karaf:camel-karaf-commands</include> <include>org.apache.camel:camel-route-parser</include> </includes> http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index e3544cc..6c7a0c0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -2268,11 +2268,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-spring-boot</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>org.apache.camel.karaf</groupId> <artifactId>camel-karaf-commands</artifactId> <version>${project.version}</version> http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/README.md ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/README.md b/platforms/commands/commands-spring-boot/README.md deleted file mode 100644 index f37986a..0000000 --- a/platforms/commands/commands-spring-boot/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Camel Shell Commands for Spring Boot - -This component is implemented as a plugin for [CRuSH Java Shell](http://www.crashub.org/), a component used by the Spring Boot platform for the remote shell. -It is essentially an adapter for the available Camel commands, responsible for passing through the options and arguments. - -# Installation - -To enable Spring Boot remote shell support: - -```xml - -<dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-remote-shell</artifactId> - <version>x.x.x</version> - <!-- use the version that is used as the depndency by the Camel --> -</dependency> - -``` - -To enable Camel Commands for the Spring Boot remote shell: - -```xml - -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-spring-boot</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> - -``` - - http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/pom.xml ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/pom.xml b/platforms/commands/commands-spring-boot/pom.xml deleted file mode 100755 index 4e6880c..0000000 --- a/platforms/commands/commands-spring-boot/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>commands</artifactId> - <version>2.20.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-commands-spring-boot</artifactId> - <packaging>jar</packaging> - <name>Camel :: Platforms :: Commands :: Spring Boot (deprecated)</name> - <description>Camel Commands using Spring Boot Shell</description> - <modelVersion>4.0.0</modelVersion> - - <properties> - <camel.osgi.export.pkg /> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-commands-core</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-remote-shell</artifactId> - <version>${spring-boot-version}</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentCamelContext.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentCamelContext.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentCamelContext.java deleted file mode 100644 index f1fc1f3..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentCamelContext.java +++ /dev/null @@ -1,31 +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.springboot.commands.crsh; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import org.crsh.cli.Argument; -import org.crsh.cli.Man; -import org.crsh.cli.Usage; - -@Retention(RetentionPolicy.RUNTIME) -@Usage("Camel context name") -@Man("Camel context name") -@Argument(name = "Camel Context", completer = CamelCompleter.class) -@interface ArgumentCamelContext { -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentRouteID.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentRouteID.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentRouteID.java deleted file mode 100644 index 1446444..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/ArgumentRouteID.java +++ /dev/null @@ -1,31 +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.springboot.commands.crsh; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import org.crsh.cli.Argument; -import org.crsh.cli.Man; -import org.crsh.cli.Usage; - -@Retention(RetentionPolicy.RUNTIME) -@Usage("Route ID") -@Man("Route ID") -@Argument(name = "Route ID", completer = CamelCompleter.class) -@interface ArgumentRouteID { -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsFacade.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsFacade.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsFacade.java deleted file mode 100644 index 68fcd6f..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsFacade.java +++ /dev/null @@ -1,132 +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.springboot.commands.crsh; - -import java.io.PrintStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; - -import org.apache.camel.CamelContext; -import org.apache.camel.Route; -import org.apache.camel.commands.AbstractCamelCommand; -import org.apache.camel.commands.AbstractContextCommand; -import org.apache.camel.commands.AbstractRouteCommand; -import org.apache.camel.commands.LocalCamelController; -import org.apache.camel.commands.StringEscape; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CamelCommandsFacade { - - protected final Logger log = LoggerFactory.getLogger(getClass().getName()); - - private LocalCamelController camelController; - private StringEscape stringEscape = new NoopStringEscape(); - - CamelCommandsFacade(LocalCamelController controller) { - this.camelController = controller; - } - - LocalCamelController getCamelController() { - return this.camelController; - } - - public <T extends AbstractCamelCommand> String runCommand(Class<T> clazz, Object... commandArgs) throws Exception { - OutputBuffer buffer = new OutputBuffer(); - PrintStream ops = buffer.getPrintStream(); - - // Trying to infer the camel context if not given - // The order of the varargs for Route Command - // [0] - route id - // [1] - camel context - if (AbstractRouteCommand.class.isAssignableFrom(clazz) && null == commandArgs[1]) { - commandArgs[1] = getCamelContextForRoute((String) commandArgs[0]); - ops.println("Automatically inferred context name : " + commandArgs[1]); - } - - // The order of the varargs for Context Command - // [0] - camel context - if (AbstractContextCommand.class.isAssignableFrom(clazz) && null == commandArgs[0]) { - commandArgs[0] = getFirstCamelContextName(); - ops.println("Context name is not provided. Using the first : " + commandArgs[0]); - } - - // Finding the right constructor - Class[] types = new Class[commandArgs.length]; - for (int i = 0; i < commandArgs.length; i++) { - types[i] = commandArgs[i].getClass(); - - // Commands require primitives - if (types[i] == Boolean.class) { - types[i] = boolean.class; - } - if (types[i] == Integer.class) { - types[i] = int.class; - } - } - - // Instantiating an object - Constructor<T> constructor = clazz.getConstructor(types); - T command = constructor.newInstance(commandArgs); - - // Some commands require StringEscape property to be set - try { - Method m = clazz.getMethod("setStringEscape", org.apache.camel.commands.StringEscape.class); - m.invoke(command, stringEscape); - } catch (Exception e) { - } - - // Executing - command.execute(camelController, ops, ops); - return buffer.toString(); - } - - private String getCamelContextForRoute(String routeId) throws Exception { - ArrayList<String> contextNames = new ArrayList<String>(); - - for (CamelContext camelContext : camelController.getLocalCamelContexts()) { - for (Route route : camelContext.getRoutes()) { - if (routeId.equals(route.getId())) { - contextNames.add(camelContext.getName()); - break; - } - } - } - - if (contextNames.size() != 1) { - StringBuffer error = new StringBuffer(); - error.append("Cannot infer CamelContext. Please provide manually."); - - if (contextNames.size() > 1) { - error.append(" Contexts : " + contextNames.toString()); - } - - throw new org.crsh.cli.impl.SyntaxException(error.toString()); - } - - return contextNames.get(0); - } - - private String getFirstCamelContextName() throws Exception { - if (camelController.getLocalCamelContexts() == null || camelController.getLocalCamelContexts().size() == 0) { - throw new org.crsh.cli.impl.SyntaxException("No CamelContexts available"); - } - - return camelController.getLocalCamelContexts().get(0).getName(); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsPlugin.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsPlugin.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsPlugin.java deleted file mode 100644 index b183ec5..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCommandsPlugin.java +++ /dev/null @@ -1,56 +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.springboot.commands.crsh; - -import org.crsh.plugin.CRaSHPlugin; -import org.springframework.beans.factory.ListableBeanFactory; - -public class CamelCommandsPlugin extends CRaSHPlugin<CamelCommandsPlugin> { - - private static CamelCommandsPlugin camelPlugin; - - private CamelCommandsFacade facade; - - private static void setCamelPlugin(CamelCommandsPlugin plugin) { - camelPlugin = plugin; - } - - static CamelCommandsPlugin getInstance() { - return camelPlugin; - } - - @Override - public CamelCommandsPlugin getImplementation() { - return this; - } - - @Override - public void init() { - ListableBeanFactory beanFactory = (ListableBeanFactory) getContext().getAttributes().get("spring.beanfactory"); - this.facade = new CamelCommandsFacade(new CamelControllerImpl(beanFactory)); - setCamelPlugin(this); - } - - @Override - public void destroy() { - // noop - } - - CamelCommandsFacade getCamelCommandsFacade() { - return this.facade; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCompleter.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCompleter.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCompleter.java deleted file mode 100644 index 1355661..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelCompleter.java +++ /dev/null @@ -1,71 +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.springboot.commands.crsh; - -import java.util.LinkedList; - -import org.apache.camel.CamelContext; -import org.apache.camel.Route; -import org.apache.camel.commands.LocalCamelController; -import org.crsh.cli.descriptor.ParameterDescriptor; -import org.crsh.cli.spi.Completer; -import org.crsh.cli.spi.Completion; - -public class CamelCompleter implements Completer { - - private LocalCamelController camelController = CamelCommandsPlugin.getInstance().getCamelCommandsFacade().getCamelController(); - - public Completion complete(ParameterDescriptor parameterDescriptor, String prefix) throws Exception { - - LinkedList<String> values = new LinkedList<String>(); - Completion.Builder builder = new Completion.Builder(prefix); - - if (parameterDescriptor.getAnnotation() instanceof ArgumentCamelContext) { - values.addAll(getContextNames()); - } - - if (parameterDescriptor.getAnnotation() instanceof ArgumentRouteID) { - values.addAll(getRouteIds()); - } - - for (String value : values) { - if (value.startsWith(prefix)) { - builder.add(value.substring(prefix.length()), true); - } - } - - return builder.build(); - } - - private LinkedList<String> getContextNames() throws Exception { - LinkedList<String> values = new LinkedList<String>(); - for (CamelContext camelContext : camelController.getLocalCamelContexts()) { - values.add(camelContext.getName()); - } - return values; - } - - private LinkedList<String> getRouteIds() throws Exception { - LinkedList<String> values = new LinkedList<String>(); - for (CamelContext camelContext : camelController.getLocalCamelContexts()) { - for (Route route : camelContext.getRoutes()) { - values.add(route.getId()); - } - } - return values; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelControllerImpl.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelControllerImpl.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelControllerImpl.java deleted file mode 100644 index af837e3..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/CamelControllerImpl.java +++ /dev/null @@ -1,83 +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.springboot.commands.crsh; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.commands.AbstractLocalCamelController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.ListableBeanFactory; - -public class CamelControllerImpl extends AbstractLocalCamelController { - - private static final Logger LOG = LoggerFactory.getLogger(CamelControllerImpl.class); - - private ListableBeanFactory beanFactory; - - CamelControllerImpl(ListableBeanFactory factory) { - beanFactory = factory; - } - - public List<CamelContext> getLocalCamelContexts() { - List<CamelContext> camelContexts = new ArrayList<CamelContext>(); - try { - camelContexts.addAll(beanFactory.getBeansOfType(CamelContext.class).values()); - } catch (Exception e) { - LOG.warn("Cannot retrieve the list of Camel contexts.", e); - } - - Collections.sort(camelContexts, new Comparator<CamelContext>() { - public int compare(CamelContext o1, CamelContext o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - - return camelContexts; - } - - public List<Map<String, String>> getCamelContexts() throws Exception { - List<Map<String, String>> answer = new ArrayList<Map<String, String>>(); - - List<CamelContext> camelContexts = getLocalCamelContexts(); - for (CamelContext camelContext : camelContexts) { - Map<String, String> row = new LinkedHashMap<String, String>(); - row.put("name", camelContext.getName()); - row.put("state", camelContext.getStatus().name()); - row.put("uptime", camelContext.getUptime()); - if (camelContext.getManagedCamelContext() != null) { - row.put("exchangesTotal", "" + camelContext.getManagedCamelContext().getExchangesTotal()); - row.put("exchangesInflight", "" + camelContext.getManagedCamelContext().getExchangesInflight()); - row.put("exchangesFailed", "" + camelContext.getManagedCamelContext().getExchangesFailed()); - } else { - row.put("exchangesTotal", "0"); - row.put("exchangesInflight", "0"); - row.put("exchangesFailed", "0"); - } - answer.add(row); - } - - return answer; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/NoopStringEscape.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/NoopStringEscape.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/NoopStringEscape.java deleted file mode 100644 index b46828e..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/NoopStringEscape.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.springboot.commands.crsh; - -import org.apache.camel.commands.StringEscape; - -class NoopStringEscape implements StringEscape { - - public String unescapeJava(String s) { - return s; - } - - public String escapeJava(String s) { - return s; - } - - public String hex(char c) { - return Character.toString(c); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/OutputBuffer.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/OutputBuffer.java b/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/OutputBuffer.java deleted file mode 100644 index c6924e4..0000000 --- a/platforms/commands/commands-spring-boot/src/main/java/org/apache/camel/springboot/commands/crsh/OutputBuffer.java +++ /dev/null @@ -1,51 +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.springboot.commands.crsh; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; - -class OutputBuffer { - - private ByteArrayOutputStream baos = new ByteArrayOutputStream(); - private PrintStream ps = new PrintStream(baos); - - public PrintStream getPrintStream() { - return ps; - } - - @Override - public String toString() { - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); - StringBuffer sb = new StringBuffer(); - String line; - String lineSeparator = System.lineSeparator(); - try { - while ((line = bufferedReader.readLine()) != null) { - sb.append(line); - sb.append(lineSeparator); - } - } catch (IOException e) { - e.printStackTrace(); - } - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/resources/META-INF/services/org.crsh.plugin.CRaSHPlugin ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/resources/META-INF/services/org.crsh.plugin.CRaSHPlugin b/platforms/commands/commands-spring-boot/src/main/resources/META-INF/services/org.crsh.plugin.CRaSHPlugin deleted file mode 100755 index 642c133..0000000 --- a/platforms/commands/commands-spring-boot/src/main/resources/META-INF/services/org.crsh.plugin.CRaSHPlugin +++ /dev/null @@ -1,17 +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. - -org.apache.camel.springboot.commands.crsh.CamelCommandsPlugin \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/commands-spring-boot/src/main/resources/crash/commands/camel/camel.groovy ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-spring-boot/src/main/resources/crash/commands/camel/camel.groovy b/platforms/commands/commands-spring-boot/src/main/resources/crash/commands/camel/camel.groovy deleted file mode 100644 index 670bffc..0000000 --- a/platforms/commands/commands-spring-boot/src/main/resources/crash/commands/camel/camel.groovy +++ /dev/null @@ -1,251 +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 crash.commands.camel - -import org.apache.camel.commands.* -import org.apache.camel.springboot.commands.crsh.ArgumentCamelContext -import org.apache.camel.springboot.commands.crsh.ArgumentRouteID -import org.apache.camel.springboot.commands.crsh.CamelCommandsFacade -import org.apache.camel.springboot.commands.crsh.CamelCommandsPlugin -import org.crsh.cli.* -import org.crsh.groovy.GroovyCommand - -@Usage("Camel related commands") -public class camel extends GroovyCommand { - - private CamelCommandsFacade getCommandsFacade() { - return context.session["crash"]. - context.getPlugin(CamelCommandsPlugin.class).getCamelCommandsFacade() - } - // =============================== - // Components and EIP - // =============================== - @Command - @Usage("Lists all Camel components available in the context.") - @Named("component-list") - public String component_list(@Required @ArgumentCamelContext String camelContext, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose) { - Boolean v = (null != verbose && Boolean.valueOf(verbose)) - return getCommandsFacade().runCommand(ComponentListCommand.class, camelContext, v) - } - - @Command - @Usage("Explains the EIP in the Camel context.") - @Named("eip-explain") - public String eip_explain(@Required @ArgumentCamelContext String camelContext, - @Required @Argument String nameOrId, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose) { - Boolean v = (null != verbose && Boolean.valueOf(verbose)) - return getCommandsFacade().runCommand(EipExplainCommand.class, camelContext, nameOrId, v) - } - - // =============================== - // Context - // =============================== - @Command - @Usage("Lists all Camel contexts.") - @Named("context-list") - public String context_list() { - return getCommandsFacade().runCommand(ContextListCommand.class) - } - - @Command - @Usage("Displays detailed information about the Camel context.") - @Named("context-info") - public String context_info(@Required @ArgumentCamelContext String camelContext, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose) { - Boolean v = (null != verbose && Boolean.valueOf(verbose)) - return getCommandsFacade().runCommand(ContextInfoCommand.class, camelContext, v) - } - - @Command - @Usage("Displays detailed information about the Camel context.") - @Named("context-inflight") - public String context_inflight(@Required @ArgumentCamelContext String camelContext, - @Usage("Sort by longest duration") - @Option(names = ["s", "sort"]) Boolean sort, - @Usage("Limit output to number of messages") - @Option(names = ["l", "limit"]) Integer limit) { - - Boolean _sort = (null != sort && Boolean.valueOf(sort)) - Integer _limit = null != limit ? limit : -1; - - if (_limit != -1) { - out.println("Limiting output to " + _limit + " messages.") - } - - return getCommandsFacade().runCommand(ContextInflightCommand.class, camelContext, _limit, _sort) - } - - @Command - @Usage("Starts the Camel context.") - @Named("context-start") - public String context_start(@Required @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(ContextStartCommand.class, camelContext) - } - - @Command - @Usage("Stops the Camel context.") - @Named("context-stop") - public String context_stop(@Required @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(ContextStopCommand.class, camelContext) - } - - @Command - @Usage("Suspends the Camel context.") - @Named("context-suspend") - public String context_suspend(@Required @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(ContextSuspendCommand.class, camelContext) - } - - @Command - @Usage("Resumes the Camel context.") - @Named("context-resume") - public String context_resume(@Required @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(ContextResumeCommand.class, camelContext) - } - - // =============================== - // Endpoints - // =============================== - @Command - @Usage("Lists Camel endpoints.") - @Named("endpoint-list") - public String endpoint_list(@Required @ArgumentCamelContext String camelContext, - @Usage("Decode URI so they are human readable") - @Option(names = ["d", "decode"]) Boolean decode, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose, - @Usage("Explain the endpoint options") - @Option(names = ["e", "explain"]) Boolean explain) { - Boolean _verbose = (null != verbose && Boolean.valueOf(verbose)) - Boolean _decode = (null != decode && Boolean.valueOf(decode)) - Boolean _explain = (null != explain && Boolean.valueOf(explain)) - return getCommandsFacade().runCommand(EndpointListCommand.class, camelContext, _decode, _verbose, _explain); - } - - @Command - @Usage("Explain all Camel endpoints available in the CamelContext.") - @Named("endpoint-explain") - public String endpoint_explain(@Required @ArgumentCamelContext String camelContext, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose, - @Usage("Filter endpoint by pattern") - @Option(names = ["f", "filter"]) String filter) { - Boolean _verbose = (null != verbose && Boolean.valueOf(verbose)) - String _filter = null != filter ? filter : "*"; - return getCommandsFacade().runCommand(EndpointExplainCommand.class, camelContext, _verbose, _filter); - } - - @Command - @Usage("Explain all Camel endpoints available in the CamelContext.") - @Named("endpoint-stats") - public String endpoint_stats(@Required @ArgumentCamelContext String camelContext, - @Usage("Decode URI so they are human readable") - @Option(names = ["d", "decode"]) Boolean decode, - @Usage("Filter the list by in,out,static,dynamic") - @Option(names = ["f", "filter"]) String filter) { - Boolean _decode = (null != decode && Boolean.valueOf(decode)) - String[] _filter = filter == null ? [] : filter.split(",") - return getCommandsFacade().runCommand(EndpointStatisticCommand.class, camelContext, _decode, _filter); - } - - @Command - @Usage("Lists all Camel REST services enlisted in the Rest Registry from a CamelContext.") - @Named("rest-registry-list") - public String rest_registry_list(@Required @ArgumentCamelContext String camelContext, - @Usage("Decode URI so they are human readable") - @Option(names = ["d", "decode"]) Boolean decode, - @Usage("Verbose output") - @Option(names = ["v", "verbose"]) Boolean verbose) { - Boolean _verbose = (null != verbose && Boolean.valueOf(verbose)) - Boolean _decode = (null != decode && Boolean.valueOf(decode)) - return getCommandsFacade().runCommand(RestRegistryListCommand.class, camelContext, _decode, _verbose); - } - - // =============================== - // Route - // =============================== - @Command - @Usage("Lists Camel routes for the given Camel context.") - @Named("route-list") - public String route_list(@Required @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteListCommand.class, camelContext) - } - - @Command - @Usage("Displays information about a Camel route") - @Named("route-info") - public String route_info(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteInfoCommand.class, route, camelContext) - } - - @Command - @Usage("Displays Camel route profile") - @Named("route-profile") - public String route_profile(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteProfileCommand.class, route, camelContext) - } - - @Command - @Usage("Display the Camel route definition in XML.") - @Named("route-show") - public String route_show(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteShowCommand.class, route, camelContext) - } - - @Command - @Usage("Resets route performance stats.") - @Named("route-reset-stats") - public String route_reset_stats( - @Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteResetStatsCommand.class, route, camelContext) - } - - @Command - @Usage("Resumes the route operation.") - @Named("route-resume") - public String route_resume(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteResumeCommand.class, route, camelContext) - } - - @Command - @Usage("Suspends the route operation.") - @Named("route-suspend") - public String route_suspend(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteSuspendCommand.class, route, camelContext) - } - - @Command - @Usage("Stops the route operation.") - @Named("route-stop") - public String route_stop(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteStopCommand.class, route, camelContext) - } - - @Command - @Usage("Starts the route operation.") - @Named("route-start") - public String route_start(@Required @ArgumentRouteID String route, @ArgumentCamelContext String camelContext) { - return getCommandsFacade().runCommand(RouteStartCommand.class, route, camelContext) - } - -} - http://git-wip-us.apache.org/repos/asf/camel/blob/413e070a/platforms/commands/pom.xml ---------------------------------------------------------------------- diff --git a/platforms/commands/pom.xml b/platforms/commands/pom.xml index d2a5b05..c4d38e9 100644 --- a/platforms/commands/pom.xml +++ b/platforms/commands/pom.xml @@ -33,7 +33,6 @@ <modules> <module>commands-core</module> <module>commands-jolokia</module> - <module>commands-spring-boot</module> </modules> </project>