[KARAF-2805] Upgrade command archetype to the new api

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3d204040
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3d204040
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3d204040

Branch: refs/heads/master
Commit: 3d204040f169025fece6eb6a116033407e70d534
Parents: 703c62f
Author: Guillaume Nodet <gno...@gmail.com>
Authored: Tue Apr 29 17:26:17 2014 +0200
Committer: Guillaume Nodet <gno...@gmail.com>
Committed: Wed Apr 30 20:04:27 2014 +0200

----------------------------------------------------------------------
 .../main/resources/archetype-resources/pom.xml  | 15 ++-------
 .../src/main/java/__command__.java              | 15 +++++----
 .../resources/OSGI-INF/blueprint/shell-log.xml  | 32 --------------------
 3 files changed, 12 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/3d204040/archetypes/command/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/archetypes/command/src/main/resources/archetype-resources/pom.xml 
b/archetypes/command/src/main/resources/archetype-resources/pom.xml
index e5b2ab0..208f292 100644
--- a/archetypes/command/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/command/src/main/resources/archetype-resources/pom.xml
@@ -31,7 +31,7 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
             <version>^project.version^</version>
         </dependency>
 
@@ -76,17 +76,8 @@
                 <configuration>
                     <instructions>
                         
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        
<Export-Package>${package}*;version=${project.version}</Export-Package>
-                        <Import-Package>
-                            !${package}*,
-                            org.apache.aries.blueprint,
-                            org.osgi.service.blueprint.container,
-                            org.osgi.service.blueprint.reflect,
-                            org.apache.felix.service.command,
-                            org.apache.karaf.shell.commands,
-                            org.apache.karaf.shell.console,
-                            *
-                        </Import-Package>
+                        
<Export-Package>${package}*;version=${project.version};-noimport:=true</Export-Package>
+                        <Karaf-Commands>${package}*</Karaf-Commands>
                     </instructions>
                 </configuration>
             </plugin>

http://git-wip-us.apache.org/repos/asf/karaf/blob/3d204040/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
----------------------------------------------------------------------
diff --git 
a/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
 
b/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
index 75ccb0a..1c6eb60 100644
--- 
a/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
+++ 
b/archetypes/command/src/main/resources/archetype-resources/src/main/java/__command__.java
@@ -21,13 +21,15 @@
 
 package ${package};
 
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.commands.Argument;
+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.Service;
 
 @Command(scope = "${scope}", name = "${cmd}", description = "${description}")
-public class ${command} extends OsgiCommandSupport {
+@Service
+public class ${command} implements Action {
 
     @Option(name = "-o", aliases = { "--option" }, description = "An option to 
the command", required = false, multiValued = false)
     private String option;
@@ -35,7 +37,8 @@ public class ${command} extends OsgiCommandSupport {
     @Argument(name = "argument", description = "Argument to the command", 
required = false, multiValued = false)
     private String argument;
 
-    protected Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
          System.out.println("Executing command ${cmd}");
          System.out.println("Option: " + option);
          System.out.println("Argument: " + argument);

http://git-wip-us.apache.org/repos/asf/karaf/blob/3d204040/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
----------------------------------------------------------------------
diff --git 
a/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
 
b/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
deleted file mode 100644
index 37c1b64..0000000
--- 
a/archetypes/command/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/blueprint/shell-log.xml
+++ /dev/null
@@ -1,32 +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.
-##---------------------------------------------------------------------------
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-#set( $cmd =  $command.toLowerCase())
-<?xml version="1.0" encoding="UTF-8"?>
-
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
-           
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0";>
-
-    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0";>
-        <command>
-            <action class="${package}.${command}">
-            </action>
-        </command>
-    </command-bundle>
-</blueprint>

Reply via email to