You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2009/07/09 10:29:22 UTC
svn commit: r792445 [2/6] - in /felix/trunk/karaf: ./ assembly/
assembly/src/main/descriptors/ assembly/src/main/filtered-resources/
assembly/src/main/filtered-resources/etc/ client/
deployer/features/src/main/resources/OSGI-INF/blueprint/ deployer/fil...
Modified: felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java Thu Jul 9 08:29:14 2009
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
public class StopCommand extends AdminCommandSupport {
@@ -25,6 +25,6 @@
protected Object doExecute() throws Exception {
getExistingInstance(instance).stop();
- return Result.SUCCESS;
+ return null;
}
}
Modified: felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java (original)
+++ felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java Thu Jul 9 08:29:14 2009
@@ -20,8 +20,8 @@
import org.apache.felix.karaf.gshell.admin.AdminService;
import org.apache.felix.karaf.gshell.admin.Instance;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
-import jline.Completor;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for server instance names.
@@ -29,7 +29,7 @@
* Displays a list of configured server instances for the Admin commands.
*
*/
-public class InstanceCompleter implements Completor {
+public class InstanceCompleter implements Completer {
private AdminService adminService;
public void setAdminService(AdminService adminService) {
Modified: felix/trunk/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml (original)
+++ felix/trunk/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml Thu Jul 9 08:29:14 2009
@@ -22,13 +22,11 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="admin/create">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.CreateCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
</command>
<command name="admin/connect">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ConnectCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -38,13 +36,11 @@
</command>
<command name="admin/list">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
</command>
<command name="admin/start">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.StartCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -54,7 +50,6 @@
</command>
<command name="admin/stop">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.StopCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -64,7 +59,6 @@
</command>
<command name="admin/destroy">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.DestroyCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -74,7 +68,6 @@
</command>
<command name="admin/change-port">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ChangePortCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -94,5 +87,4 @@
<property name="adminService" ref="adminService" />
</bean>
-
</blueprint>
Modified: felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg (original)
+++ felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg Thu Jul 9 08:29:14 2009
@@ -55,7 +55,8 @@
#
# The following property value will add the system folder as a repo.
#
-org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/system@snapshots,file:${karaf.base}/system@snapshots
+org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/system@snapshots, \
+ file:${karaf.base}/system@snapshots
#
# Comma separated list of repositories scanned when resolving an artifact.
@@ -68,6 +69,12 @@
# @snapshots : the repository contains snaphots
# @noreleases : the repository does not contain any released artifacts
#
-# The following property value will add the system folders as a repo.
+# The following property value will add the system folder as a repo.
#
-org.ops4j.pax.url.mvn.repositories=file:${karaf.base}/system@snapshots,file:${user.home}/.m2/repository@snapshots,http://repo1.maven.org/maven2,http://people.apache.org/repo/m2-snapshot-repository@snapshots@noreleases,http://svn.apache.org/repos/asf/servicemix/m2-repo
+org.ops4j.pax.url.mvn.repositories= \
+ http://repo1.maven.org/maven2, \
+ http://people.apache.org/repo/m2-snapshot-repository@snapshots@noreleases, \
+ http://repository.ops4j.org/maven2, \
+ http://svn.apache.org/repos/asf/servicemix/m2-repo, \
+ http://repository.springsource.com/maven/bundles/release, \
+ http://repository.springsource.com/maven/bundles/external
Modified: felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties (original)
+++ felix/trunk/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties Thu Jul 9 08:29:14 2009
@@ -19,3 +19,4 @@
org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
karaf.name=${karaf.name}
+xml.catalog.files=
Copied: felix/trunk/karaf/gshell/gshell-commands/pom.xml (from r792359, felix/trunk/karaf/gshell/gshell-osgi/pom.xml)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/pom.xml?p2=felix/trunk/karaf/gshell/gshell-commands/pom.xml&p1=felix/trunk/karaf/gshell/gshell-osgi/pom.xml&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/pom.xml (original)
+++ felix/trunk/karaf/gshell/gshell-commands/pom.xml Thu Jul 9 08:29:14 2009
@@ -28,39 +28,31 @@
</parent>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.osgi</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.commands</artifactId>
<packaging>bundle</packaging>
<version>1.2.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: GShell OSGi Commands</name>
+ <name>Apache Felix Karaf :: GShell Various Commands</name>
<description>
- Provides the OSGi GShell commands
+ Provides SSH support to the console
</description>
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -70,13 +62,11 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
- <Private-Package>!*</Private-Package>
<_versionpolicy>${bnd.version.policy}</_versionpolicy>
</instructions>
</configuration>
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,103 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.FileReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * Concatenate and print files and/or URLs.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "cat", description = "Displays the content of a file or url")
+public class CatAction extends OsgiCommandSupport {
+
+ @Option(name="-n", description = "Number the output lines, starting at 1.")
+ private boolean displayLineNumbers;
+
+ @Argument(required = true, multiValued = true)
+ private List<String> paths;
+
+ protected Object doExecute() throws Exception {
+ //
+ // Support "-" if length is one, and read from io.in
+ // This will help test command pipelines.
+ //
+ if (paths.size() == 1 && "-".equals(paths.get(0))) {
+ log.info("Printing STDIN");
+ cat(new BufferedReader(new InputStreamReader(System.in)));
+ }
+ else {
+ for (String filename : paths) {
+ BufferedReader reader;
+
+ // First try a URL
+ try {
+ URL url = new URL(filename);
+ log.info("Printing URL: " + url);
+ reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ }
+ catch (MalformedURLException ignore) {
+ // They try a file
+ File file = new File(filename);
+ log.info("Printing file: " + file);
+ reader = new BufferedReader(new FileReader(file));
+ }
+
+ try {
+ cat(reader);
+ }
+ finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void cat(final BufferedReader reader) throws IOException
+ {
+ String line;
+ int lineno = 1;
+
+ while ((line = reader.readLine()) != null) {
+ if (displayLineNumbers) {
+ System.out.print(String.format("%6d ", lineno++));
+ }
+ System.out.println(line);
+ }
+ }
+}
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,11 @@
+package org.apache.felix.karaf.gshell.commands;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Jul 9, 2009
+ * Time: 1:06:45 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class EchoCommand {
+}
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.karaf.gshell.commands.utils.PumpStreamHandler;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+
+/**
+ * Execute system processes.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "exec", description = "Execute system processes")
+public class ExecuteAction extends OsgiCommandSupport {
+
+ @Argument(description = "Arguments", required = true, multiValued = true)
+ private List<String> args;
+
+ protected Object doExecute() throws Exception {
+ ProcessBuilder builder = new ProcessBuilder(args);
+
+ log.info("Executing: {}", builder.command());
+
+ Process p = builder.start();
+
+ PumpStreamHandler handler = new PumpStreamHandler(System.in, System.out, System.err);
+ handler.attach(p);
+ handler.start();
+
+ log.debug("Waiting for process to exit...");
+
+ int status = p.waitFor();
+
+
+ log.info("Process exited w/status: {}", status);
+
+ handler.stop();
+
+ return status;
+ }
+
+}
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,98 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Command;
+
+
+@Command(scope = "shell", name="grep", description="Print lines matching a pattern")
+public class GrepAction extends OsgiCommandSupport {
+
+ @Argument(required=true, description="Regular expression")
+ private String regex;
+
+ @Option(name="-n", aliases = { "--line-number" }, description="Prefix each line of output with the line number within its input file.")
+ private boolean lineNumber;
+
+ @Option(name = "-v", aliases = { "--invert-match" }, description = "Invert the sense of matching, to select non-matching lines.")
+ private boolean invertMatch;
+
+ @Option(name = "-w", aliases = { "--word-regexp" }, description = "Select only those lines containing matches that form whole " +
+ "words. The test is that the matching substring must either be " +
+ "at the beginning of the line, or preceded by a non-word constituent " +
+ "character. Similarly, it must be either at the end of " +
+ "the line or followed by a non-word constituent character. " +
+ "Word-constituent characters are letters, digits, and the underscore.")
+ private boolean wordRegexp;
+
+ @Option(name = "-x", aliases = { "--line-regexp" }, description = "Select only those matches that exactly match the whole line.")
+ private boolean lineRegexp;
+
+ protected Object doExecute() throws Exception {
+ String regexp = regex;
+ if (wordRegexp) {
+ regexp = "\\b" + regexp + "\\b";
+ }
+ if (lineRegexp) {
+ regexp = "^" + regexp + "$";
+ } else {
+ regexp = ".*" + regexp + ".*";
+ }
+ Pattern p = Pattern.compile(regexp);
+ try {
+ int lineno = 1;
+ String line;
+ Reader r = new InputStreamReader(System.in);
+ while ((line = readLine(r)) != null) {
+ if (p.matcher(line).matches() ^ invertMatch) {
+ if (lineNumber) {
+ System.out.print(String.format("%6d ", lineno++));
+ }
+ System.out.println(line);
+ lineno++;
+ }
+ }
+ } catch (IOException e) {
+ }
+ return null;
+ }
+
+ private String readLine(Reader in) throws IOException {
+ StringBuffer buf = new StringBuffer();
+ while (true) {
+ int i = in.read();
+ if (i == -1 && buf.length() == 0) {
+ throw new IOException("break");
+ }
+ if (i == -1 || i == '\n' || i == '\r') {
+ return buf.toString();
+ }
+ buf.append((char) i);
+ }
+ }
+
+}
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java (from r792359, felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java&p1=felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java Thu Jul 9 08:29:14 2009
@@ -14,19 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.felix.karaf.gshell.osgi;
-
-import java.util.List;
-
-import org.apache.geronimo.gshell.clp.Option;
-import org.osgi.framework.Bundle;
-
-public class StopBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.stop();
- }
- }
+package org.apache.felix.karaf.gshell.commands;
+/**
+ * TODO
+ */
+public class HistoryAction {
}
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java (from r792359, felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java&p1=felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java Thu Jul 9 08:29:14 2009
@@ -14,19 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.felix.karaf.gshell.osgi;
-
-import java.util.List;
-
-import org.apache.geronimo.gshell.clp.Option;
-import org.osgi.framework.Bundle;
-
-public class StopBundle extends BundlesCommand {
-
- protected void doExecute(List<Bundle> bundles) throws Exception {
- for (Bundle bundle : bundles) {
- bundle.stop();
- }
- }
+package org.apache.felix.karaf.gshell.commands;
+/**
+ * TODO
+ */
+public class InfoAction {
}
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+
+/**
+ * Execute a Java standard application.
+ *
+ * <p>By default looks for static main(String[]) to execute, but
+ * you can specify a different static method that takes a String[]
+ * to execute instead.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "java", description = "Execute a Java standard application")
+public class JavaAction extends OsgiCommandSupport {
+
+ @Option(name="-m", aliases={"--method"}, description="Invoke a named method")
+ private String methodName = "main";
+
+ @Argument(index=0, name = "className", description="The name of the class to invoke", required=true)
+ private String className;
+
+ @Argument(index=1, name = "args", description="Arguments to pass to the METHOD of CLASSNAME")
+ private List<String> args;
+
+ protected Object doExecute() throws Exception {
+ boolean info = log.isInfoEnabled();
+
+ Class type = Thread.currentThread().getContextClassLoader().loadClass(className);
+ if (info) {
+ log.info("Using type: " + type);
+ }
+
+ Method method = type.getMethod(methodName, String[].class);
+ if (info) {
+ log.info("Using method: " + method);
+ }
+
+ if (info) {
+ log.info("Invoking w/arguments: {}", args);
+ }
+
+ Object result = method.invoke(null, args);
+
+ if (info) {
+ log.info("Result: " + result);
+ }
+
+ return null;
+ }
+
+}
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java (from r792359, felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java&p1=felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java Thu Jul 9 08:29:14 2009
@@ -14,20 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.felix.karaf.gshell.admin.internal.commands;
+package org.apache.felix.karaf.gshell.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import java.util.Collection;
-public class ChangePortCommand extends AdminCommandSupport {
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
- @Argument(index=0, required=true, description="The instance name")
- private String instance = null;
+@Command(scope = "shell", name = "printf", description = "Format and print arguments")
+public class PrintfAction extends OsgiCommandSupport {
- @Argument(index=1, required=true, description="The new port")
- private int port = 0;
+ @Argument(index=0, required=true)
+ private String format;
+
+ @Argument(index=1, multiValued=true, required=true)
+ private Collection<Object> arguments = null;
protected Object doExecute() throws Exception {
- getExistingInstance(instance).changePort(port);
- return Result.SUCCESS;
+ System.out.printf(format, arguments.toArray());
+ return null;
}
}
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java (from r792359, felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java&p1=felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java Thu Jul 9 08:29:14 2009
@@ -14,20 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.felix.karaf.gshell.admin.internal.commands;
+package org.apache.felix.karaf.gshell.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
-public class ChangePortCommand extends AdminCommandSupport {
+@Command(scope = "shell", name = "sleep", description = "Sleep for a bit then wake up")
+public class SleepAction extends OsgiCommandSupport {
- @Argument(index=0, required=true, description="The instance name")
- private String instance = null;
-
- @Argument(index=1, required=true, description="The new port")
- private int port = 0;
+ @Argument(required=true)
+ private int time = -1;
protected Object doExecute() throws Exception {
- getExistingInstance(instance).changePort(port);
- return Result.SUCCESS;
+ log.info("Sleeping for {}", time);
+
+ try {
+ Thread.sleep(time);
+ }
+ catch (InterruptedException ignore) {
+ log.debug("Sleep was interrupted... :-(");
+ }
+
+ log.info("Awake now");
+ return null;
}
}
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java (from r792359, felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java&p1=felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java Thu Jul 9 08:29:14 2009
@@ -16,14 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.felix.karaf.gshell.commands;
-package org.apache.geronimo.gshell.commands.text;
-
-import java.io.BufferedInputStream;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -31,89 +34,96 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.vfs.FileObject;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.io.Closer;
-import org.apache.geronimo.gshell.vfs.FileObjects;
-import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
/**
* Sort lines of text
*
- * TODO: remove this file when gshell is upgraded
- *
+ * @version $Rev: 722776 $ $Date: 2008-12-03 05:59:59 +0100 (Wed, 03 Dec 2008) $
*/
-public class SortAction extends VfsActionSupport {
+@Command(scope = "shell", name = "sort", description = "Write sorted concatenation of all FILE(s) to standard output.")
+public class SortAction extends OsgiCommandSupport {
- @Option(name = "-f")
+ @Option(name = "-f", aliases = { "-ignore-case" }, description = "fold lower case to upper case characters")
private boolean caseInsensitive;
- @Option(name = "-r")
+ @Option(name = "-r", aliases = { "--reverse" }, description = "reverse the result of comparisons")
private boolean reverse;
- @Option(name = "-u")
+ @Option(name = "-u", aliases = { "--unique" }, description = "output only the first of an equal run")
private boolean unique;
- @Option(name = "-t")
+ @Option(name = "-t", aliases = { "--field-separator" }, description = "use SEP instead of non-blank to blank transition")
private String separator;
- @Option(name = "-b")
+ @Option(name = "-b", aliases = { "--ignore-leading-blanks" }, description = "ignore leading blanks")
private boolean ignoreBlanks;
- @Option(name = "-k", argumentRequired = true, multiValued = true)
+ @Option(name = "-k", aliases = { "--key" }, multiValued = true)
private List<String> sortFields;
- @Option(name = "-n")
+ @Option(name = "-n", aliases = { "--numeric-sort" }, description = "compare according to string numerical value")
private boolean numeric;
- @Argument(index = 0, required=false)
- private String path;
-
-
- public Object execute(CommandContext context) throws Exception {
- assert context != null;
+ @Argument(index = 0, required = false, multiValued = true)
+ private List<String> paths;
- if (path != null) {
- FileObject file = resolveFile(context, path);
- try {
- sort(context, file);
- }
- finally {
- FileObjects.close(file);
+ public Object doExecute() throws Exception {
+ if (paths != null && paths.size() > 0) {
+ List<String> lines = new ArrayList<String>();
+ for (String filename : paths) {
+ BufferedReader reader;
+
+ // First try a URL
+ try {
+ URL url = new URL(filename);
+ log.info("Printing URL: " + url);
+ reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ }
+ catch (MalformedURLException ignore) {
+ // They try a file
+ File file = new File(filename);
+ log.info("Printing file: " + file);
+ reader = new BufferedReader(new FileReader(file));
+ }
+
+ try {
+ read(reader, lines);
+ }
+ finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
}
+ sort(lines, System.out);
}
else {
- sort(context.getIo().inputStream, context.getIo().out);
+ sort(System.in, System.out);
}
- return Result.SUCCESS;
+ return null;
}
- protected void sort(final CommandContext context, final FileObject file) throws Exception {
- assert context != null;
- assert file != null;
-
- ensureFileExists(file);
- ensureFileHasContent(file);
- ensureFileIsReadable(file);
-
- BufferedInputStream input = new BufferedInputStream(file.getContent().getInputStream());
- try {
- sort(input, context.getIo().out);
- }
- finally {
- Closer.close(input);
+ protected void read(BufferedReader r, List<String> lines) throws Exception {
+ for (String s = r.readLine(); s != null; s = r.readLine()) {
+ lines.add(s);
}
}
- protected void sort(InputStream input, PrintWriter out) throws Exception {
- BufferedReader r = new BufferedReader(new InputStreamReader(input));
+ protected void sort(InputStream input, PrintStream out) throws Exception {
List<String> strings = new ArrayList<String>();
- for (String s = r.readLine(); s != null; s = r.readLine()) {
- strings.add(s);
- }
+ BufferedReader r = new BufferedReader(new InputStreamReader(input));
+ read(r, strings);
+ sort(strings, out);
+ }
+
+ protected void sort(List<String> strings, PrintStream out) throws Exception {
char sep = (separator == null || separator.length() == 0) ? '\0' : separator.charAt(0);
Collections.sort(strings, new SortComparator(caseInsensitive, reverse, ignoreBlanks, numeric, sep, sortFields));
String last = null;
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java (from r792359, felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java&p1=felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java Thu Jul 9 08:29:14 2009
@@ -16,14 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
-
-import org.apache.sshd.server.PasswordAuthenticator;
-
-public class BogusPasswordAuthenticator implements PasswordAuthenticator {
-
- public Object authenticate(String username, String password) {
- return (username != null && username.equals(password)) ? username : null;
- }
+package org.apache.felix.karaf.gshell.commands;
+/**
+ * TODO
+ */
+public class SourceAction {
}
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,232 @@
+/*
+ * 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.felix.karaf.gshell.commands.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies standard output and error of children streams to standard output and error of the parent.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class PumpStreamHandler
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private OutputStream err;
+
+ private Thread outputThread;
+
+ private Thread errorThread;
+
+ private StreamPumper inputPump;
+
+ //
+ // NOTE: May want to use a ThreadPool here, 3 threads per/pair seems kinda expensive :-(
+ //
+
+ public PumpStreamHandler(final InputStream in, final OutputStream out, final OutputStream err) {
+ assert in != null;
+ assert out != null;
+ assert err != null;
+
+ this.in = in;
+ this.out = out;
+ this.err = err;
+ }
+
+ public PumpStreamHandler(final OutputStream out, final OutputStream err) {
+ this(null, out, err);
+ }
+
+ public PumpStreamHandler(final OutputStream outAndErr) {
+ this(outAndErr, outAndErr);
+ }
+
+ /**
+ * Set the input stream from which to read the standard output of the child.
+ */
+ public void setChildOutputStream(final InputStream in) {
+ assert in != null;
+
+ createChildOutputPump(in, out);
+ }
+
+ /**
+ * Set the input stream from which to read the standard error of the child.
+ */
+ public void setChildErrorStream(final InputStream in) {
+ assert in != null;
+
+ if (err != null) {
+ createChildErrorPump(in, err);
+ }
+ }
+
+ /**
+ * Set the output stream by means of which input can be sent to the child.
+ */
+ public void setChildInputStream(final OutputStream out) {
+ assert out != null;
+
+ if (in != null) {
+ inputPump = createInputPump(in, out, true);
+ }
+ else {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ }
+
+ /**
+ * Attach to a child streams from the given process.
+ *
+ * @param p The process to attach to.
+ */
+ public void attach(final Process p) {
+ assert p != null;
+
+ setChildInputStream(p.getOutputStream());
+ setChildOutputStream(p.getInputStream());
+ setChildErrorStream(p.getErrorStream());
+ }
+ /**
+ * Start pumping the streams.
+ */
+ public void start() {
+ if (outputThread != null) {
+ outputThread.start();
+ }
+
+ if (errorThread != null) {
+ errorThread.start();
+ }
+
+ if (inputPump != null) {
+ Thread inputThread = new Thread(inputPump);
+ inputThread.setDaemon(true);
+ inputThread.start();
+ }
+ }
+
+ /**
+ * Stop pumping the streams.
+ */
+ public void stop() {
+ if (outputThread != null) {
+ try {
+ outputThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (errorThread != null) {
+ try {
+ errorThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (inputPump != null) {
+ inputPump.stop();
+ }
+
+ try {
+ err.flush();
+ } catch (IOException e) { }
+ try {
+ out.flush();
+ } catch (IOException e) { }
+ }
+
+ /**
+ * Create the pump to handle child output.
+ */
+ protected void createChildOutputPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ outputThread = createPump(in, out);
+ }
+
+ /**
+ * Create the pump to handle error output.
+ */
+ protected void createChildErrorPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ errorThread = createPump(in, out);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the given output stream.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ return createPump(in, out, false);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream.
+ *
+ * @param in The input stream to copy from.
+ * @param out The output stream to copy to.
+ * @param closeWhenExhausted If true close the inputstream.
+ * @return A thread object that does the pumping.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ final Thread result = new Thread(new StreamPumper(in, out, closeWhenExhausted));
+ result.setDaemon(true);
+ return result;
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream. Used for standard input.
+ */
+ protected StreamPumper createInputPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ StreamPumper pumper = new StreamPumper(in, out, closeWhenExhausted);
+ pumper.setAutoflush(true);
+ return pumper;
+ }
+}
\ No newline at end of file
Added: felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java (added)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java Thu Jul 9 08:29:14 2009
@@ -0,0 +1,199 @@
+/*
+ * 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.felix.karaf.gshell.commands.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies all data from an input stream to an output stream.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class StreamPumper
+ implements Runnable
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private volatile boolean finish;
+
+ private volatile boolean finished;
+
+ private boolean closeWhenExhausted;
+
+ private boolean autoflush;
+
+ private Exception exception;
+
+ private int bufferSize = 128;
+
+ private boolean started;
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ * @param closeWhenExhausted If true, the output stream will be closed when
+ * the input is exhausted.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ this.in = in;
+ this.out = out;
+ this.closeWhenExhausted = closeWhenExhausted;
+ }
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out) {
+ this(in, out, false);
+ }
+
+ /**
+ * Set whether data should be flushed through to the output stream.
+ *
+ * @param autoflush If true, push through data; if false, let it be buffered
+ */
+ public void setAutoflush(boolean autoflush) {
+ this.autoflush = autoflush;
+ }
+
+ /**
+ * Copies data from the input stream to the output stream.
+ *
+ * Terminates as soon as the input stream is closed or an error occurs.
+ */
+ public void run() {
+ synchronized (this) {
+ started = true;
+ }
+ finished = false;
+ finish = false;
+
+ final byte[] buf = new byte[bufferSize];
+
+ int length;
+ try {
+ while ((length = in.read(buf)) > 0 && !finish) {
+ out.write(buf, 0, length);
+ if (autoflush) {
+ out.flush();
+ }
+ }
+ out.flush();
+ }
+ catch (Exception e) {
+ synchronized (this) {
+ exception = e;
+ }
+ }
+ finally {
+ if (closeWhenExhausted) {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ finished = true;
+
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Tells whether the end of the stream has been reached.
+ *
+ * @return true If the stream has been exhausted.
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+
+ /**
+ * This method blocks until the stream pumper finishes.
+ *
+ * @see #isFinished()
+ */
+ public synchronized void waitFor() throws InterruptedException {
+ while (!isFinished()) {
+ wait();
+ }
+ }
+
+ /**
+ * Set the size in bytes of the read buffer.
+ *
+ * @param bufferSize the buffer size to use.
+ * @throws IllegalStateException if the StreamPumper is already running.
+ */
+ public synchronized void setBufferSize(final int bufferSize) {
+ if (started) {
+ throw new IllegalStateException("Cannot set buffer size on a running StreamPumper");
+ }
+
+ this.bufferSize = bufferSize;
+ }
+
+ /**
+ * Get the size in bytes of the read buffer.
+ *
+ * @return The size of the read buffer.
+ */
+ public synchronized int getBufferSize() {
+ return bufferSize;
+ }
+
+ /**
+ * Get the exception encountered, if any.
+ *
+ * @return The Exception encountered; or null if there was none.
+ */
+ public synchronized Exception getException() {
+ return exception;
+ }
+
+ /**
+ * Stop the pumper as soon as possible.
+ *
+ * Note that it may continue to block on the input stream
+ * but it will really stop the thread as soon as it gets EOF
+ * or any byte, and it will be marked as finished.
+ */
+ public synchronized void stop() {
+ finish = true;
+
+ notifyAll();
+ }
+}
\ No newline at end of file
Copied: felix/trunk/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml (from r792359, felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml?p2=felix/trunk/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml&p1=felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml Thu Jul 9 08:29:14 2009
@@ -20,15 +20,26 @@
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="packages/exports">
- <action class="org.apache.felix.karaf.gshell.packages.ExportsCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
- </command>
- <command name="packages/imports">
- <action class="org.apache.felix.karaf.gshell.packages.ImportsCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <command name="shell/cat">
+ <action class="org.apache.felix.karaf.gshell.commands.CatAction"/>
+ </command>
+ <command name="shell/exec">
+ <action class="org.apache.felix.karaf.gshell.commands.ExecuteAction"/>
+ </command>
+ <command name="shell/grep">
+ <action class="org.apache.felix.karaf.gshell.commands.GrepAction"/>
+ </command>
+ <command name="shell/java">
+ <action class="org.apache.felix.karaf.gshell.commands.JavaAction"/>
+ </command>
+ <command name="shell/printf">
+ <action class="org.apache.felix.karaf.gshell.commands.PrintfAction"/>
+ </command>
+ <command name="shell/sleep">
+ <action class="org.apache.felix.karaf.gshell.commands.SleepAction"/>
+ </command>
+ <command name="shell/sort">
+ <action class="org.apache.felix.karaf.gshell.commands.SortAction"/>
</command>
</command-bundle>
Copied: felix/trunk/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java (from r792359, felix/trunk/karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java?p2=felix/trunk/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java&p1=felix/trunk/karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java (original)
+++ felix/trunk/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java Thu Jul 9 08:29:14 2009
@@ -16,26 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.geronimo.gshell.commands.text;
+package org.apache.felix.karaf.gshell.commands;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import junit.framework.TestCase;
-import org.apache.geronimo.gshell.ansi.AnsiRenderWriter;
-/**
- * TODO: remove this file when gshell is upgraded
- */
public class SortTest extends TestCase {
- public void testAnsi() {
- AnsiRenderWriter w = new AnsiRenderWriter(System.out);
- w.println("Hey, @|cyan Hello| world");
- w.flush();
- }
-
public void testFieldIndexesDefaultSep() {
SortAction.SortComparator comparator = new SortAction.SortComparator(false, false, false, false, '\0', null);
List<Integer> indexes = comparator.getFieldIndexes(" ad re t ");
Modified: felix/trunk/karaf/gshell/gshell-config/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/pom.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/pom.xml (original)
+++ felix/trunk/karaf/gshell/gshell-config/pom.xml Thu Jul 9 08:29:14 2009
@@ -40,7 +40,7 @@
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -54,16 +54,6 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- </dependency>
</dependencies>
<build>
@@ -76,10 +66,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java Thu Jul 9 08:29:14 2009
@@ -21,8 +21,8 @@
public class CancelCommand extends ConfigCommandSupport {
protected void doExecute(ConfigurationAdmin admin) throws Exception {
- this.variables.parent().unset(PROPERTY_CONFIG_PID);
- this.variables.parent().unset(PROPERTY_CONFIG_PROPS);
+ session.put(PROPERTY_CONFIG_PID, null);
+ session.put(PROPERTY_CONFIG_PROPS, null);
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java Thu Jul 9 08:29:14 2009
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -37,13 +37,13 @@
// Get config admin service.
ServiceReference ref = getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
if (ref == null) {
- io.out.println("ConfigurationAdmin service is unavailable.");
+ System.out.println("ConfigurationAdmin service is unavailable.");
return null;
}
try {
ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService(ref);
if (admin == null) {
- io.out.println("ConfigAdmin service is unavailable.");
+ System.out.println("ConfigAdmin service is unavailable.");
return null;
}
@@ -56,7 +56,7 @@
}
protected Dictionary getEditedProps() throws Exception {
- return (Dictionary) this.variables.parent().get(PROPERTY_CONFIG_PROPS);
+ return (Dictionary) this.session.get(PROPERTY_CONFIG_PROPS);
}
protected abstract void doExecute(ConfigurationAdmin admin) throws Exception;
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java Thu Jul 9 08:29:14 2009
@@ -18,8 +18,8 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.service.cm.ConfigurationAdmin;
public class EditCommand extends ConfigCommandSupport {
@@ -31,13 +31,13 @@
boolean force;
protected void doExecute(ConfigurationAdmin admin) throws Exception {
- String oldPid = (String) this.variables.get(PROPERTY_CONFIG_PID);
+ String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID);
if (oldPid != null && !oldPid.equals(pid) && !force) {
- io.err.println("Another config is being edited. Cancel / update first, or use the --force option");
+ System.err.println("Another config is being edited. Cancel / update first, or use the --force option");
return;
}
Dictionary props = admin.getConfiguration(pid).getProperties();
- this.variables.parent().set(PROPERTY_CONFIG_PID, pid);
- this.variables.parent().set(PROPERTY_CONFIG_PROPS, props);
+ this.session.put(PROPERTY_CONFIG_PID, pid);
+ this.session.put(PROPERTY_CONFIG_PROPS, props);
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java Thu Jul 9 08:29:14 2009
@@ -19,9 +19,9 @@
import java.util.Dictionary;
import java.util.Enumeration;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class ListCommand extends ConfigCommandSupport {
@@ -31,18 +31,18 @@
protected void doExecute(ConfigurationAdmin admin) throws Exception {
Configuration[] configs = admin.listConfigurations(query);
for (Configuration config : configs) {
- io.out.println("----------------------------------------------------------------");
- io.out.println("Pid: " + config.getPid());
+ System.out.println("----------------------------------------------------------------");
+ System.out.println("Pid: " + config.getPid());
if (config.getFactoryPid() != null) {
- io.out.println("FactoryPid: " + config.getFactoryPid());
+ System.out.println("FactoryPid: " + config.getFactoryPid());
}
- io.out.println("BundleLocation: " + config.getBundleLocation());
+ System.out.println("BundleLocation: " + config.getBundleLocation());
if (config.getProperties() != null) {
- io.out.println("Properties:");
+ System.out.println("Properties:");
Dictionary props = config.getProperties();
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
- io.out.println(" " + key + " = " + props.get(key));
+ System.out.println(" " + key + " = " + props.get(key));
}
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java Thu Jul 9 08:29:14 2009
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
/**
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java Thu Jul 9 08:29:14 2009
@@ -18,12 +18,12 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
public class PropDelCommand extends ConfigCommandSupport {
- @Argument(index = 0, required = true, description = "the property to delete")
+ @Argument(name = "prop", index = 0, required = true, description = "the property to delete")
String prop;
protected void doExecute(ConfigurationAdmin admin) throws Exception {
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java Thu Jul 9 08:29:14 2009
@@ -30,7 +30,7 @@
} else {
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
- io.out.println(" " + key + " = " + props.get(key));
+ System.out.println(" " + key + " = " + props.get(key));
}
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java Thu Jul 9 08:29:14 2009
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
public class PropSetCommand extends ConfigCommandSupport {
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java Thu Jul 9 08:29:14 2009
@@ -28,11 +28,11 @@
if (props == null) {
System.err.println("No configuration is being edited. Run the edit command first");
} else {
- String pid = (String) this.variables.parent().get(PROPERTY_CONFIG_PID);
+ String pid = (String) this.session.get(PROPERTY_CONFIG_PID);
Configuration cfg = admin.getConfiguration(pid, null);
cfg.update(props);
- this.variables.parent().unset(PROPERTY_CONFIG_PID);
- this.variables.parent().unset(PROPERTY_CONFIG_PROPS);
+ this.session.put(PROPERTY_CONFIG_PID, null);
+ this.session.put(PROPERTY_CONFIG_PROPS, null);
}
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java Thu Jul 9 08:29:14 2009
@@ -23,8 +23,8 @@
import java.util.Collection;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationEvent;
@@ -36,7 +36,7 @@
* Displays a list of existing config admin configurations for completion.
*
*/
-public class ConfigurationCompleter implements Completor, ConfigurationListener {
+public class ConfigurationCompleter implements Completer, ConfigurationListener {
private final StringsCompleter delegate = new StringsCompleter();
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java Thu Jul 9 08:29:14 2009
@@ -19,15 +19,9 @@
package org.apache.felix.karaf.gshell.config.completers;
-import java.util.Dictionary;
-import java.util.Enumeration;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
-import org.apache.felix.karaf.gshell.config.ConfigCommandSupport;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for Configuration Admin properties.
@@ -35,22 +29,24 @@
* Displays a list of existing properties based on the current configuration being edited.
*
*/
-public class ConfigurationPropertyCompleter implements Completor {
+public class ConfigurationPropertyCompleter implements Completer {
public int complete(final String buffer, final int cursor, final List candidates) {
- Variables vars = ShellContextHolder.get().getVariables();
- if (vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PID) == null) {
- return -1;
- }
-
- Dictionary props = (Dictionary) vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
- StringsCompleter delegate = new StringsCompleter();
-
- for (Enumeration e = props.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- delegate.getStrings().add(key);
- }
+ // TODO: currently we have no way to access the session which is being run in this thread
+ return -1;
- return delegate.complete(buffer, cursor, candidates);
+// if (vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PID) == null) {
+// return -1;
+// }
+//
+// Dictionary props = (Dictionary) vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
+// StringsCompleter delegate = new StringsCompleter();
+//
+// for (Enumeration e = props.keys(); e.hasMoreElements();) {
+// String key = (String) e.nextElement();
+// delegate.getStrings().add(key);
+// }
+//
+// return delegate.complete(buffer, cursor, candidates);
}
}
Modified: felix/trunk/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml (original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml Thu Jul 9 08:29:14 2009
@@ -21,62 +21,48 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="config/cancel">
- <action class="org.apache.felix.karaf.gshell.config.CancelCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.CancelCommand"/>
</command>
<command name="config/edit">
- <action class="org.apache.felix.karaf.gshell.config.EditCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.EditCommand"/>
<completers>
<ref component-id="configCompleter" />
<null/>
</completers>
</command>
<command name="config/list">
- <action class="org.apache.felix.karaf.gshell.config.ListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.ListCommand"/>
</command>
<command name="config/propdel">
- <action class="org.apache.felix.karaf.gshell.config.PropDelCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropDelCommand"/>
<completers>
<ref component-id="configPropertyCompleter" />
<null/>
</completers>
</command>
<command name="config/proplist">
- <action class="org.apache.felix.karaf.gshell.config.PropListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropListCommand"/>
</command>
<command name="config/propset">
- <action class="org.apache.felix.karaf.gshell.config.PropSetCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropSetCommand"/>
<completers>
<ref component-id="configPropertyCompleter" />
<null/>
</completers>
</command>
<command name="config/update">
- <action class="org.apache.felix.karaf.gshell.config.UpdateCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.UpdateCommand"/>
</command>
</command-bundle>
<bean id="configCompleter" class="org.apache.felix.karaf.gshell.config.completers.ConfigurationCompleter" init-method="init">
<property name="admin" ref="configAdmin"/>
</bean>
+ <service ref="configCompleter" interface="org.osgi.service.cm.ConfigurationListener" />
<bean id="configPropertyCompleter" class="org.apache.felix.karaf.gshell.config.completers.ConfigurationPropertyCompleter" />
<reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
- <service ref="configCompleter" interface="org.osgi.service.cm.ConfigurationListener" />
</blueprint>