karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgoody...@apache.org
Subject svn commit: r1197186 - in /karaf/branches/karaf-2.2.x: assemblies/apache-karaf/src/main/filtered-resources/demos/command/ demos/ demos/command/ demos/command/src/ demos/command/src/main/ demos/command/src/main/java/ demos/command/src/main/java/org/ dem...
Date Thu, 03 Nov 2011 15:29:29 GMT
Author: jgoodyear
Date: Thu Nov  3 15:29:28 2011
New Revision: 1197186

URL: http://svn.apache.org/viewvc?rev=1197186&view=rev
Log:
[KARAF-980] Add demo for extending Karaf's console commands.

Add new demo for extending console command.
Update manual entry for correct embedding of completer tag.


Added:
    karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/
    karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt
  (with props)
    karaf/branches/karaf-2.2.x/demos/command/
    karaf/branches/karaf-2.2.x/demos/command/NOTICE
    karaf/branches/karaf-2.2.x/demos/command/pom.xml   (with props)
    karaf/branches/karaf-2.2.x/demos/command/src/
    karaf/branches/karaf-2.2.x/demos/command/src/main/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
  (with props)
    karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
  (with props)
    karaf/branches/karaf-2.2.x/demos/command/src/main/resources/
    karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/
    karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/
    karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
  (with props)
Modified:
    karaf/branches/karaf-2.2.x/demos/pom.xml
    karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/extending-console.conf

Added: karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt
(added)
+++ karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt
Thu Nov  3 15:29:28 2011
@@ -0,0 +1,61 @@
+/* 
+ * 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.
+ */
+
+EXTEND CONSOLE COMMAND EXAMPLE
+==============================
+
+Purpose
+-------
+Demonstrate how to extend a console command. 
+
+
+Prerequisites for Running this Example
+--------------------------------------
+You must have the following installed on your machine:
+
+   - JDK 1.5 or higher.
+
+   - Apache Maven 2.2.1 or higher.
+
+
+Building and Deploying
+----------------------
+This example will produce a bundle, containing a custom command
+and its command completer.
+
+To build the demo console command invoke the following command:
+
+  mvn install
+
+To deploy the console command invoke the following command on the Karaf
+console: 
+
+  karaf@root> osgi:install -s mvn:org.apache.karaf.demos/org.apache.karaf.demos.command/${pom.version}
+
+Upon successful installation the bundle ID will be presented.
+
+To test the custom command type the following on the Karaf console:
+
+  karaf@root> mycommand:hello 
+  Executing My Command Demo
+  karaf@root>
+
+To test the command completer press tab after typing the first few
+characters of 'mycommand'.
+
+For more information on Extending Karaf Console Commands please visit:
+http://karaf.apache.org/manual/${pom.version}/developers-guide/extending-console.html

Propchange: karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/demos/command/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: karaf/branches/karaf-2.2.x/demos/command/NOTICE
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/command/NOTICE?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/command/NOTICE (added)
+++ karaf/branches/karaf-2.2.x/demos/command/NOTICE Thu Nov  3 15:29:28 2011
@@ -0,0 +1,48 @@
+Apache Karaf
+Copyright 2010 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Tanuki Software (http://www.tanukisoftware.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0

Added: karaf/branches/karaf-2.2.x/demos/command/pom.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/command/pom.xml?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/command/pom.xml (added)
+++ karaf/branches/karaf-2.2.x/demos/command/pom.xml Thu Nov  3 15:29:28 2011
@@ -0,0 +1,67 @@
+<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/maven-v4_0_0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.demos</groupId>
+        <artifactId>demos</artifactId>
+        <version>2.2.5-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.karaf.demos.command</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: Demos :: Extend Console Command</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.4</version>
+                <configuration>
+                    <instructions>
+                        <Import-Package>
+                            org.apache.felix.service.command,
+                            org.apache.felix.gogo.commands,
+                            org.apache.karaf.shell.console,
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: karaf/branches/karaf-2.2.x/demos/command/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
(added)
+++ karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
Thu Nov  3 15:29:28 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.demos.command;
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+@Command(scope = "mycommand", name = "hello", description="Says hello")
+public class MyCommand extends OsgiCommandSupport {
+
+    @Argument(index = 0, name = "arg", description = "The command argument", required = false,
multiValued = false)
+    String arg = null;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        System.out.println("Executing My Command Demo");
+        return null;
+    }
+}

Propchange: karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
(added)
+++ karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
Thu Nov  3 15:29:28 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.demos.command;
+
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.apache.karaf.shell.console.Completer;
+
+import java.util.List;
+
+/**
+* <p>
+* My completer.
+* </p>
+*/
+
+public class MyCompleter implements Completer {
+
+    /**
+     * @param buffer it's the beginning string typed by the user
+     * @param cursor it's the position of the cursor
+     * @param candidates the list of completions proposed to the user
+     */
+    public int complete(String buffer, int cursor, List candidates) {
+
+        StringsCompleter delegate = new StringsCompleter();
+        delegate.getStrings().add("one");
+        delegate.getStrings().add("two");
+        delegate.getStrings().add("three");
+        return delegate.complete(buffer, cursor, candidates);
+    }
+}

Propchange: karaf/branches/karaf-2.2.x/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml?rev=1197186&view=auto
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
(added)
+++ karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
Thu Nov  3 15:29:28 2011
@@ -0,0 +1,35 @@
+<?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">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+        <command name="mycommand/hello">
+            <action class="org.apache.karaf.demos.command.MyCommand"/>
+            <completers>
+                <ref component-id="myCompleter"/>
+                <null/>
+            </completers>
+        </command>
+    </command-bundle>
+
+    <bean id="myCompleter" class="org.apache.karaf.demos.command.MyCompleter"/>
+
+</blueprint>

Propchange: karaf/branches/karaf-2.2.x/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: karaf/branches/karaf-2.2.x/demos/pom.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/demos/pom.xml?rev=1197186&r1=1197185&r2=1197186&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/demos/pom.xml (original)
+++ karaf/branches/karaf-2.2.x/demos/pom.xml Thu Nov  3 15:29:28 2011
@@ -37,6 +37,7 @@
         <module>web</module>
         <module>branding</module>
         <module>dump</module>
-    </modules>
+        <module>command</module>
+  </modules>
 
-</project>
\ No newline at end of file
+</project>

Modified: karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/extending-console.conf
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/extending-console.conf?rev=1197186&r1=1197185&r2=1197186&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/extending-console.conf
(original)
+++ karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/extending-console.conf
Thu Nov  3 15:29:28 2011
@@ -279,11 +279,11 @@ Using Blueprint, you can "inject" the co
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
         <command name="test/hello">
             <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
+            <completers>
+                <ref component-id="simpleCompleter"/>
+                <null/>
+            </completers>
         </command>
-        <completers>
-          <ref component-id="simpleCompleter"/>
-          <null/>
-        </completers>
     </command-bundle>
 
     <bean id="simpleCompleter" class="org.apache.karaf.shell.samples.SimpleCompleter"/>



Mime
View raw message