Repository: camel Updated Branches: refs/heads/master 6060710e9 -> da614b730
http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java index 72ebffb..bc929a9 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteSuspend.java @@ -17,15 +17,17 @@ package org.apache.camel.karaf.commands; import org.apache.camel.commands.RouteSuspendCommand; -import org.apache.felix.gogo.commands.Command; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.lifecycle.Service; -@Command(scope = "camel", name = " route-suspend", description = "Suspend a Camel route") +@Command(scope = "camel", name = "route-suspend", description = "Suspend a Camel route") +@Service public class RouteSuspend extends AbstractRouteCommand { @Override - protected Object doExecute() throws Exception { + public Object execute() throws Exception { RouteSuspendCommand command = new RouteSuspendCommand(route, context); - return command.execute(camelController, System.out, System.err); + return command.execute(this, System.out, System.err); } } http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelCompleterSupport.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelCompleterSupport.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelCompleterSupport.java deleted file mode 100644 index fa5e5cb..0000000 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelCompleterSupport.java +++ /dev/null @@ -1,33 +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.completers; - -import org.apache.camel.commands.LocalCamelController; -import org.apache.karaf.shell.console.Completer; - -/** - * The abstract base class for completers. - */ -public abstract class CamelCompleterSupport implements Completer { - - protected LocalCamelController camelController; - - public void setCamelController(LocalCamelController camelController) { - this.camelController = camelController; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelContextCompleter.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelContextCompleter.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelContextCompleter.java index 266f25c..b64503a 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelContextCompleter.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/CamelContextCompleter.java @@ -18,23 +18,28 @@ package org.apache.camel.karaf.commands.completers; import java.util.List; -import jline.console.completer.StringsCompleter; import org.apache.camel.CamelContext; +import org.apache.camel.karaf.commands.internal.CamelControllerImpl; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.karaf.shell.api.console.CommandLine; +import org.apache.karaf.shell.api.console.Completer; +import org.apache.karaf.shell.api.console.Session; +import org.apache.karaf.shell.support.completers.StringsCompleter; /** - * A JLine completer for the Camel contexts. + * A completer for the Camel contexts. */ -public class CamelContextCompleter extends CamelCompleterSupport { +@Service +public class CamelContextCompleter extends CamelControllerImpl implements Completer { - @SuppressWarnings({"unchecked", "rawtypes"}) - public int complete(String buffer, int cursor, List candidates) { + public int complete(Session session, CommandLine commandLine, List<String> candidates) { try { StringsCompleter delegate = new StringsCompleter(); - List<CamelContext> camelContexts = camelController.getLocalCamelContexts(); + List<CamelContext> camelContexts = getLocalCamelContexts(); for (CamelContext camelContext : camelContexts) { delegate.getStrings().add(camelContext.getName()); } - return delegate.complete(buffer, cursor, candidates); + return delegate.complete(session, commandLine, candidates); } catch (Exception e) { // nothing to do, no completion } http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java index fbcd1d3..060624e 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java @@ -19,22 +19,28 @@ package org.apache.camel.karaf.commands.completers; import java.util.List; import java.util.Map; -import jline.console.completer.StringsCompleter; +import org.apache.camel.karaf.commands.internal.CamelControllerImpl; +import org.apache.karaf.shell.api.action.Action; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.karaf.shell.api.console.CommandLine; +import org.apache.karaf.shell.api.console.Completer; +import org.apache.karaf.shell.api.console.Session; +import org.apache.karaf.shell.support.completers.StringsCompleter; /** - * A Jline completer for the Camel routes. + * A completer for the Camel routes. */ -public class RouteCompleter extends CamelCompleterSupport { +@Service +public class RouteCompleter extends CamelControllerImpl implements Completer { - @SuppressWarnings({"unchecked", "rawtypes"}) - public int complete(String buffer, int cursor, List candidates) { + public int complete(Session session, CommandLine commandLine, List<String> candidates) { try { StringsCompleter delegate = new StringsCompleter(); - List<Map<String, String>> routes = camelController.getRoutes(null); + List<Map<String, String>> routes = getRoutes(null); for (Map<String, String> row : routes) { delegate.getStrings().add(row.get("routeId")); } - return delegate.complete(buffer, cursor, candidates); + return delegate.complete(session, commandLine, candidates); } catch (Exception e) { // nothing to do, no completion } http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java index 25d9ae9..cda4993 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java @@ -25,6 +25,8 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.commands.AbstractLocalCamelController; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.slf4j.Logger; @@ -37,6 +39,7 @@ public class CamelControllerImpl extends AbstractLocalCamelController { private static final Logger LOG = LoggerFactory.getLogger(CamelControllerImpl.class); + @Reference private BundleContext bundleContext; public void setBundleContext(BundleContext bundleContext) { http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/StringEscape.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/StringEscape.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/StringEscape.java index 36dfd31..71c0c00 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/StringEscape.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/StringEscape.java @@ -16,7 +16,16 @@ */ package org.apache.camel.karaf.commands.internal; -public class StringEscape implements org.apache.camel.commands.StringEscape { +public final class StringEscape implements org.apache.camel.commands.StringEscape { + + private static StringEscape instance = new StringEscape(); + + private StringEscape() { + } + + public static StringEscape getInstance() { + return instance; + } @Override public String unescapeJava(String str) { http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/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 deleted file mode 100644 index 30e9a8f..0000000 --- a/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml +++ /dev/null @@ -1,252 +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. ---> -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy"> - - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0"> - <command name="camel/context-list"> - <action class="org.apache.camel.karaf.commands.ContextList"> - <property name="camelController" ref="camelController"/> - </action> - </command> - <command name="camel/context-info"> - <action class="org.apache.camel.karaf.commands.ContextInfo"> - <property name="camelController" ref="camelController"/> - <property name="stringEscape" ref="stringEscape"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/context-start"> - <action class="org.apache.camel.karaf.commands.ContextStart"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/context-stop"> - <action class="org.apache.camel.karaf.commands.ContextStop"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/context-suspend"> - <action class="org.apache.camel.karaf.commands.ContextSuspend"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/context-resume"> - <action class="org.apache.camel.karaf.commands.ContextResume"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/context-inflight"> - <action class="org.apache.camel.karaf.commands.ContextInflight"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/route-list"> - <action class="org.apache.camel.karaf.commands.RouteList"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/route-info"> - <action class="org.apache.camel.karaf.commands.RouteInfo"> - <property name="camelController" ref="camelController"/> - <property name="stringEscape" ref="stringEscape"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-profile"> - <action class="org.apache.camel.karaf.commands.RouteProfile"> - <property name="camelController" ref="camelController"/> - <property name="stringEscape" ref="stringEscape"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-reset-stats"> - <action class="org.apache.camel.karaf.commands.RouteResetStats"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <null/> - </completers> - </command> - <command name="camel/route-show"> - <action class="org.apache.camel.karaf.commands.RouteShow"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-start"> - <action class="org.apache.camel.karaf.commands.RouteStart"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-stop"> - <action class="org.apache.camel.karaf.commands.RouteStop"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-resume"> - <action class="org.apache.camel.karaf.commands.RouteResume"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/route-suspend"> - <action class="org.apache.camel.karaf.commands.RouteSuspend"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="routeCompleter"/> - <ref component-id="camelContextCompleter"/> - </completers> - </command> - <command name="camel/eip-explain"> - <action class="org.apache.camel.karaf.commands.EipExplain"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/endpoint-list"> - <action class="org.apache.camel.karaf.commands.EndpointList"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/endpoint-stats"> - <action class="org.apache.camel.karaf.commands.EndpointStats"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/endpoint-explain"> - <action class="org.apache.camel.karaf.commands.EndpointExplain"> - <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"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <null/> - </completers> - </command> - <command name="camel/rest-api-doc"> - <action class="org.apache.camel.karaf.commands.RestApiDoc"> - <property name="camelController" ref="camelController"/> - </action> - <completers> - <ref component-id="camelContextCompleter"/> - <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 name="camel/component-list"> - <action class="org.apache.camel.karaf.commands.ComponentList"> - <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"> - <property name="camelController" ref="camelController"/> - </bean> - - <bean id="routeCompleter" class="org.apache.camel.karaf.commands.completers.RouteCompleter"> - <property name="camelController" ref="camelController"/> - </bean> - - <bean id="camelController" class="org.apache.camel.karaf.commands.internal.CamelControllerImpl"> - <property name="bundleContext" ref="blueprintBundleContext"/> - </bean> - - <bean id="stringEscape" class="org.apache.camel.karaf.commands.internal.StringEscape"/> - -</blueprint> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/da614b73/platforms/karaf/features/pom.xml ---------------------------------------------------------------------- diff --git a/platforms/karaf/features/pom.xml b/platforms/karaf/features/pom.xml index 259d522..844e14b 100644 --- a/platforms/karaf/features/pom.xml +++ b/platforms/karaf/features/pom.xml @@ -77,7 +77,7 @@ </dependency> <dependency> <groupId>org.apache.karaf.shell</groupId> - <artifactId>org.apache.karaf.shell.console</artifactId> + <artifactId>org.apache.karaf.shell.core</artifactId> <version>${karaf4-version}</version> <scope>provided</scope> </dependency>