You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/05 23:25:21 UTC
[2/6] [KARAF-2805] Convert remaining commands to the new model
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/info/PojoInfoProvider.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/info/PojoInfoProvider.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/info/PojoInfoProvider.java
index b929475..c6a131e 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/info/PojoInfoProvider.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/info/PojoInfoProvider.java
@@ -20,7 +20,7 @@ package org.apache.karaf.shell.commands.impl.info;
import java.util.Properties;
-import org.apache.karaf.shell.commands.InfoProvider;
+import org.apache.karaf.shell.commands.info.InfoProvider;
public class PojoInfoProvider implements InfoProvider {
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoProvider.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoProvider.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoProvider.java
new file mode 100644
index 0000000..b66cfae
--- /dev/null
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/info/InfoProvider.java
@@ -0,0 +1,30 @@
+/*
+ * 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.karaf.shell.commands.info;
+
+import java.util.Properties;
+
+/**
+ * A bundle can publish a service with this interface to offer some informations for the shell:info command
+ */
+public interface InfoProvider {
+
+ public String getName();
+
+ public Properties getProperties();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/pom.xml
----------------------------------------------------------------------
diff --git a/system/command/pom.xml b/system/command/pom.xml
index eb2c5d7..cf17321 100644
--- a/system/command/pom.xml
+++ b/system/command/pom.xml
@@ -46,15 +46,8 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
@@ -84,13 +77,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- org.apache.karaf.system,
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
- *
- </Import-Package>
+ <Karaf-Commands>*</Karaf-Commands>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/AbstractSystemAction.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/AbstractSystemAction.java b/system/command/src/main/java/org/apache/karaf/system/commands/AbstractSystemAction.java
deleted file mode 100644
index 0ffdae9..0000000
--- a/system/command/src/main/java/org/apache/karaf/system/commands/AbstractSystemAction.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.karaf.system.commands;
-
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.system.SystemService;
-
-public abstract class AbstractSystemAction extends OsgiCommandSupport {
-
- @Reference
- protected SystemService systemService;
-
- public void setSystemService(SystemService systemService) {
- this.systemService = systemService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/FrameworkOptions.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/FrameworkOptions.java b/system/command/src/main/java/org/apache/karaf/system/commands/FrameworkOptions.java
index 13f7d42..9e16a7d 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/FrameworkOptions.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/FrameworkOptions.java
@@ -16,18 +16,21 @@
*/
package org.apache.karaf.system.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.karaf.system.FrameworkType;
+import org.apache.karaf.system.SystemService;
/**
* Command for enabling/disabling debug logging on the OSGi framework
*/
@Command(scope = "system", name = "framework", description = "OSGi Framework options.")
@Service
-public class FrameworkOptions extends AbstractSystemAction {
+public class FrameworkOptions implements Action {
@Option(name = "-debug", aliases={"--enable-debug"}, description="Enable debug for the OSGi framework", required = false, multiValued = false)
boolean debug;
@@ -38,8 +41,11 @@ public class FrameworkOptions extends AbstractSystemAction {
@Argument(name = "framework", required = false, description = "Name of the OSGi framework to use")
String framework;
+ @Reference
+ SystemService systemService;
+
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
if (!debug^nodebug && framework == null) {
System.out.printf("Current OSGi framework is %s%n", systemService.getFramework().name());
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/Name.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/Name.java b/system/command/src/main/java/org/apache/karaf/system/commands/Name.java
index 6e6eb41..a716d82 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/Name.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/Name.java
@@ -16,21 +16,29 @@
*/
package org.apache.karaf.system.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.inject.Service;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.system.SystemService;
/**
* Command to shut down Karaf container.
*/
@Command(scope = "system", name = "name", description = "Show or change Karaf instance name.")
@Service
-public class Name extends AbstractSystemAction {
+public class Name implements Action {
@Argument(name = "name", index = 0, description = "New name for the instance", required = false, multiValued = false)
String name;
- protected Object doExecute() throws Exception {
+ @Reference
+ SystemService systemService;
+
+ @Override
+ public Object execute() throws Exception {
if (name == null) {
System.out.println(systemService.getName());
} else {
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/Shutdown.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/Shutdown.java b/system/command/src/main/java/org/apache/karaf/system/commands/Shutdown.java
index a95b9d0..b8b4b41 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/Shutdown.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/Shutdown.java
@@ -16,11 +16,13 @@
*/
package org.apache.karaf.system.commands;
-import jline.console.ConsoleReader;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.system.SystemService;
/**
@@ -28,7 +30,7 @@ import org.apache.karaf.system.SystemService;
*/
@Command(scope = "system", name = "shutdown", description = "Shutdown Karaf.")
@Service
-public class Shutdown extends AbstractSystemAction {
+public class Shutdown implements Action {
@Option(name = "-f", aliases = "--force", description = "Force the shutdown without confirmation message.", required = false, multiValued = false)
boolean force = false;
@@ -52,7 +54,14 @@ public class Shutdown extends AbstractSystemAction {
" to wait. The word now is an alias for +0.", required = false, multiValued = false)
String time;
- protected Object doExecute() throws Exception {
+ @Reference
+ SystemService systemService;
+
+ @Reference
+ Session session;
+
+ @Override
+ public Object execute() throws Exception {
if (force) {
if (reboot) {
@@ -71,8 +80,7 @@ public class Shutdown extends AbstractSystemAction {
} else {
msg = String.format("Confirm: halt instance %s (yes/no): ", karafName);
}
- ConsoleReader reader = (ConsoleReader) session.get(".jline.reader");
- String str = reader.readLine(msg);
+ String str = session.readLine(msg, null);
if (str.equalsIgnoreCase("yes")) {
if (reboot) {
systemService.reboot(time, determineSwipeType());
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/StartLevel.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/StartLevel.java b/system/command/src/main/java/org/apache/karaf/system/commands/StartLevel.java
index 1d7dfdf..e91c15a 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/StartLevel.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/StartLevel.java
@@ -16,10 +16,11 @@
*/
package org.apache.karaf.system.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.karaf.system.SystemService;
/**
@@ -27,12 +28,16 @@ import org.apache.karaf.system.SystemService;
*/
@Command(scope = "system", name = "start-level", description = "Gets or sets the system start level.")
@Service
-public class StartLevel extends AbstractSystemAction {
+public class StartLevel implements Action {
@Argument(index = 0, name = "level", description = "The new system start level to set", required = false, multiValued = false)
Integer level;
- protected Object doExecute() throws Exception {
+ @Reference
+ SystemService systemService;
+
+ @Override
+ public Object execute() throws Exception {
if (level == null) {
System.out.println("Level " + systemService.getStartLevel());
} else {
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/SystemProperty.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/SystemProperty.java b/system/command/src/main/java/org/apache/karaf/system/commands/SystemProperty.java
index b03d40f..37c2a1e 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/SystemProperty.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/SystemProperty.java
@@ -16,24 +16,32 @@
*/
package org.apache.karaf.system.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.inject.Service;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-
import java.io.File;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.system.SystemService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
/**
* Command that allow access to system properties easily.
*/
@Command(scope = "system", name = "property", description = "Get or set a system property.")
@Service
-public class SystemProperty extends AbstractSystemAction {
+public class SystemProperty implements Action {
@Option(name = "-p", aliases = {"--persistent"}, description = "Persist the new value to the etc/system.properties file")
boolean persistent;
@@ -50,8 +58,14 @@ public class SystemProperty extends AbstractSystemAction {
@Argument(index = 1, name = "value", required = false, description = "New value for the system property")
String value;
+ @Reference
+ BundleContext bundleContext;
+
+ @Reference
+ SystemService systemService;
+
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
if (key == null && value == null) {
Properties props = (Properties) System.getProperties().clone();
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
----------------------------------------------------------------------
diff --git a/system/command/src/main/java/org/apache/karaf/system/commands/Version.java b/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
index 4dd0d2c..9837aaa 100644
--- a/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
+++ b/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
@@ -16,14 +16,21 @@
*/
package org.apache.karaf.system.commands;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.system.SystemService;
@Command(scope = "system", name = "version", description = "Display the instance version")
@Service
-public class Version extends AbstractSystemAction {
+public class Version implements Action {
- protected Object doExecute() throws Exception {
+ @Reference
+ SystemService systemService;
+
+ @Override
+ public Object execute() throws Exception {
System.out.println(systemService.getVersion());
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml
----------------------------------------------------------------------
diff --git a/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml b/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml
deleted file mode 100644
index 6c9f328..0000000
--- a/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml
+++ /dev/null
@@ -1,25 +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.2.0"
- scan="org.apache.karaf.system.commands.*" />
-
-</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/web/command/pom.xml
----------------------------------------------------------------------
diff --git a/web/command/pom.xml b/web/command/pom.xml
index 7c76a98..738cb9b 100644
--- a/web/command/pom.xml
+++ b/web/command/pom.xml
@@ -47,16 +47,9 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
@@ -72,11 +65,6 @@
<artifactId>org.apache.karaf.util</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.table</artifactId>
- <scope>provided</scope>
- </dependency>
</dependencies>
<build>
@@ -107,6 +95,7 @@
<Private-Package>
org.apache.karaf.web.commands
</Private-Package>
+ <Karaf-Commands>*</Karaf-Commands>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/web/command/src/main/java/org/apache/karaf/web/commands/List.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/List.java b/web/command/src/main/java/org/apache/karaf/web/commands/List.java
index c2508ad..a862a45 100644
--- a/web/command/src/main/java/org/apache/karaf/web/commands/List.java
+++ b/web/command/src/main/java/org/apache/karaf/web/commands/List.java
@@ -16,20 +16,19 @@
*/
package org.apache.karaf.web.commands;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.shell.inject.Service;
-import org.apache.karaf.shell.table.Col;
-import org.apache.karaf.shell.table.ShellTable;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Col;
+import org.apache.karaf.shell.support.table.ShellTable;
import org.apache.karaf.web.WebBundle;
import org.apache.karaf.web.WebContainerService;
-
@Command(scope = "web", name = "list", description = "Lists details for war bundles.")
@Service
-public class List extends OsgiCommandSupport {
+public class List implements Action {
@Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
boolean noFormat;
@@ -40,8 +39,9 @@ public class List extends OsgiCommandSupport {
public void setWebContainerService(WebContainerService webContainerService) {
this.webContainerService = webContainerService;
}
-
- public Object doExecute() throws Exception {
+
+ @Override
+ public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column(new Col("ID"));
table.column(new Col("State"));
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/Start.java b/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
index f87846e..41d6634 100644
--- a/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
+++ b/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
@@ -16,16 +16,16 @@
*/
package org.apache.karaf.web.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.karaf.web.WebContainerService;
@Command(scope = "web", name = "start", description = "Start the web context of given bundles.")
@Service
-public class Start extends OsgiCommandSupport {
+public class Start implements Action {
@Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
java.util.List<Long> ids;
@@ -36,8 +36,9 @@ public class Start extends OsgiCommandSupport {
public void setWebContainerService(WebContainerService webContainerService) {
this.webContainerService = webContainerService;
}
-
- public Object doExecute() throws Exception {
+
+ @Override
+ public Object execute() throws Exception {
webContainerService.start(ids);
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java b/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
index bff6180..76fd141 100644
--- a/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
+++ b/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
@@ -16,20 +16,16 @@
*/
package org.apache.karaf.web.commands;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.karaf.web.WebContainerService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
@Command(scope = "web", name = "stop", description = "Stop the web context of given bundles.")
@Service
-public class Stop extends OsgiCommandSupport {
+public class Stop implements Action {
@Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
java.util.List<Long> ids;
@@ -41,7 +37,8 @@ public class Stop extends OsgiCommandSupport {
this.webContainerService = webContainerService;
}
- public Object doExecute() throws Exception {
+ @Override
+ public Object execute() throws Exception {
webContainerService.stop(ids);
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/571c6f99/web/command/src/main/resources/OSGI-INF/blueprint/web-commands.xml
----------------------------------------------------------------------
diff --git a/web/command/src/main/resources/OSGI-INF/blueprint/web-commands.xml b/web/command/src/main/resources/OSGI-INF/blueprint/web-commands.xml
deleted file mode 100644
index b00ac40..0000000
--- a/web/command/src/main/resources/OSGI-INF/blueprint/web-commands.xml
+++ /dev/null
@@ -1,25 +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.2.0"
- scan="org.apache.karaf.web.commands.*" />
-
-</blueprint>
\ No newline at end of file