You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/06/20 12:51:19 UTC
svn commit: r669849 [1/2] - in /geronimo/gshell/trunk:
gshell-api/src/main/java/org/apache/geronimo/gshell/command/
gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/
gshell-commands/gshell-builtins/src/main/java/org/apac...
Author: jdillon
Date: Fri Jun 20 03:51:18 2008
New Revision: 669849
URL: http://svn.apache.org/viewvc?rev=669849&view=rev
Log:
Updated all commands to implement CommandAction and not use CommandSupport, dropped Executable, phasing out CommandContainer
Added:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java (with props)
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java
- copied, changed from r669210, geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Executable.java
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java (with props)
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java (with props)
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java (with props)
geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandActionDescriptor.java
- copied, changed from r669210, geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
Removed:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Executable.java
geronimo/gshell/trunk/gshell-commands/gshell-command-support/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
Modified:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ClearCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/PluginDescriptor.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineBuilder.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultLayoutManager.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultShell.java
geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/ExecutingVisitor.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
geronimo/gshell/trunk/src/uml/GShell.mdxml
Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java?rev=669849&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java Fri Jun 20 03:51:18 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.geronimo.gshell.command;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Command
+{
+ String getId();
+
+ CommandAction getAction();
+
+ CommandDocumentor getDocumentor();
+
+ CommandCompletor getCompletor();
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java (from r669210, geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Executable.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java?p2=geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java&p1=geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Executable.java&r1=669210&r2=669849&rev=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Executable.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java Fri Jun 20 03:51:18 2008
@@ -24,22 +24,13 @@
*
* @version $Rev$ $Date$
*/
-public interface Executable
+public interface CommandAction
{
- @Deprecated
- Result SUCCESS = Result.SUCCESS;
-
- @Deprecated
- Result FAILURE = Result.FAILURE;
-
- // TODO: Change this to ExecutionContext, and/or implement a lifecycle to inject the context, and leave Executable context free?
-
- Object execute(CommandContext context, Object... args) throws Exception;
-
- //
- // Result
- //
+ Object execute(CommandContext context) throws Exception;
+ /**
+ * ???
+ */
enum Result
{
SUCCESS,
Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java?rev=669849&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java Fri Jun 20 03:51:18 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.command;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CommandCompletor
+{
+ // TODO:
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompletor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java Fri Jun 20 03:51:18 2008
@@ -24,22 +24,12 @@
*
* @version $Rev$ $Date$
*/
+@Deprecated
public interface CommandContainer
{
- Executable getExecutable();
-
- // TODO: Change to ShellContext, let the container build its own CommandContext
+ Object execute(CommandContext context) throws Exception;
- Object execute(CommandContext context, Object... args) throws Exception;
-
- // TODO: Completor
-
- // TODO: Documentor (for --help and `help <command>`) handling
-
- //
- // Locator
- //
-
+ @Deprecated
interface Locator
{
CommandContainer locate(String id);
Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java Fri Jun 20 03:51:18 2008
@@ -28,6 +28,8 @@
*/
public interface CommandContext
{
+ Object[] getArguments();
+
IO getIo();
Variables getVariables();
Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java?rev=669849&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java Fri Jun 20 03:51:18 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.command;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CommandDocumentor
+{
+ // TODO:
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumentor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java?rev=669849&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java Fri Jun 20 03:51:18 2008
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.command;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CommandFactory
+{
+ Command create(String id) throws Exception;
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java Fri Jun 20 03:51:18 2008
@@ -23,11 +23,15 @@
import org.apache.bsf.BSFManager;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.CommandException;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.console.Console;
import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.io.IO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URI;
@@ -41,8 +45,10 @@
*/
@CommandComponent(id="gshell-bsf:script", description="Provides generic scripting language execution support")
public class ScriptCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
private String language;
@Option(name="-l", aliases={"--language"}, description="Specify the scripting language")
@@ -62,10 +68,15 @@
@Option(name="-e", aliases={"--expression"}, description="Evaluate the given expression")
private String expression;
+ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
@Argument(description="A file or URL to execute")
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+
//
// TODO: When given a file/url, try to figure out language from ext if language not given
// https://issues.apache.org/jira/browse/GSHELL-49
@@ -150,6 +161,6 @@
runner.run();
}
- return SUCCESS;
+ return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ClearCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ClearCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ClearCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ClearCommand.java Fri Jun 20 03:51:18 2008
@@ -21,8 +21,12 @@
import jline.ConsoleReader;
import org.apache.geronimo.gshell.ansi.ANSI;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.PrintWriter;
@@ -33,19 +37,33 @@
*/
@CommandComponent(id="gshell-builtins:clear", description="Clear the terminal screen")
public class ClearCommand
- extends CommandSupport
+ implements CommandAction
{
- protected Object doExecute() throws Exception {
- ConsoleReader reader = new ConsoleReader(io.inputStream, new PrintWriter(io.outputStream, true), /*bindings*/ null, io.getTerminal());
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+ IO io = context.getIo();
+
+ // We can only clear the screen if ANSI is enabled, so complain and fail otherwise
if (!ANSI.isEnabled()) {
- io.out.println("ANSI is not enabled. The clear command is not functional");
- }
- else {
- reader.clearScreen();
- return SUCCESS;
+ io.error("ANSI is not enabled. The clear command is not functional");
+ return Result.FAILURE;
}
-
- return SUCCESS;
+
+ //
+ // FIXME: Need to have the framework provide a reader, which is initialized correctly?
+ //
+
+ ConsoleReader reader = new ConsoleReader(
+ io.inputStream,
+ new PrintWriter(io.outputStream, true),
+ null, // bindings
+ io.getTerminal());
+
+ reader.clearScreen();
+
+ return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java Fri Jun 20 03:51:18 2008
@@ -19,12 +19,16 @@
package org.apache.geronimo.gshell.commands.builtins;
-import java.util.List;
-
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
/**
* A simple command to <em>echo</em> all given arguments to the commands standard output.
@@ -33,15 +37,22 @@
*/
@CommandComponent(id="gshell-builtins:echo", description="Echo or print arguments to STDOUT")
public class EchoCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Option(name="-n", description="Do not print the trailing newline character")
private boolean trailingNewline = true;
+ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
@Argument(description="Arguments")
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+
if (args != null) {
int c=0;
@@ -57,6 +68,6 @@
io.out.println();
}
- return SUCCESS;
+ return Result.SUCCESS;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java Fri Jun 20 03:51:18 2008
@@ -20,9 +20,12 @@
package org.apache.geronimo.gshell.commands.builtins;
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.notification.ExitNotification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Exit the current shell.
@@ -31,18 +34,19 @@
*/
@CommandComponent(id="gshell-builtins:exit", description="Exit the shell")
public class ExitCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Argument(description="System exit code")
private int exitCode = 0;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
log.info("Exiting w/code: {}", exitCode);
- //
- // DO NOT Call System.exit() !!!
- //
-
+ // Do not call System.exit(), ask the shell to exit instead.
throw new ExitNotification(exitCode);
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java Fri Jun 20 03:51:18 2008
@@ -23,16 +23,20 @@
import org.apache.geronimo.gshell.ansi.Renderer;
import org.apache.geronimo.gshell.application.ApplicationManager;
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContainer;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.command.annotation.Requirement;
+import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.layout.LayoutManager;
import org.apache.geronimo.gshell.model.layout.AliasNode;
import org.apache.geronimo.gshell.model.layout.CommandNode;
import org.apache.geronimo.gshell.model.layout.GroupNode;
import org.apache.geronimo.gshell.model.layout.Node;
import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Display help
@@ -41,8 +45,10 @@
*/
@CommandComponent(id="gshell-builtins:help", description="Show command help")
public class HelpCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Requirement
private ApplicationManager applicationManager;
@@ -67,7 +73,15 @@
this.layoutManager = layoutManager;
}
- protected Object doExecute() throws Exception {
+ // HACK:
+ private IO io;
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ // HACK:
+ io = context.getIo();
+
io.out.println();
if (command == null) {
@@ -77,7 +91,7 @@
displayCommandHelp(command);
}
- return SUCCESS;
+ return Result.SUCCESS;
}
private void displayAvailableCommands() throws Exception {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java Fri Jun 20 03:51:18 2008
@@ -19,16 +19,20 @@
package org.apache.geronimo.gshell.commands.builtins;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
import org.apache.geronimo.gshell.application.DefaultVariables;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.io.IO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
/**
* Set a variable or property.
@@ -37,8 +41,10 @@
*/
@CommandComponent(id="gshell-builtins:set", description="Set a variable")
public class SetCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
enum Mode
{
VARIABLE,
@@ -48,10 +54,16 @@
@Option(name="-m", aliases={"--mode"}, description="Set mode")
private Mode mode = Mode.VARIABLE;
+ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
@Argument(description="Variable definition")
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+ Variables variables = context.getVariables();
+
// No args... list all properties or variables
if (args == null || args.size() == 0) {
switch (mode) {
@@ -86,7 +98,7 @@
}
}
- return SUCCESS;
+ return Result.SUCCESS;
}
//
@@ -106,12 +118,12 @@
break;
case VARIABLE:
- setVariable(namevalue);
+ setVariable(variables, namevalue);
break;
}
}
- return SUCCESS;
+ return Result.SUCCESS;
}
class NameValue
@@ -158,14 +170,14 @@
private void setProperty(final String namevalue) {
NameValue nv = parse(namevalue);
- log.info("Setting system property: {}={}", nv.name, nv.value);
+ // log.info("Setting system property: {}={}", nv.name, nv.value);
ensureIsIdentifier(nv.name);
System.setProperty(nv.name, nv.value);
}
- private void setVariable(final String namevalue) {
+ private void setVariable(final Variables vars, final String namevalue) {
NameValue nv = parse(namevalue);
log.info("Setting variable: {}={}", nv.name, nv.value);
@@ -173,8 +185,6 @@
ensureIsIdentifier(nv.name);
// Command vars always has a parent, set only makes sence when setting in parent's scope
- Variables vars = variables.parent();
-
- vars.set(nv.name, nv.value);
+ vars.parent().set(nv.name, nv.value);
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java Fri Jun 20 03:51:18 2008
@@ -19,20 +19,19 @@
package org.apache.geronimo.gshell.commands.builtins;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
/**
* Read and execute commands from a file/url in the current shell environment.
@@ -41,15 +40,19 @@
*/
@CommandComponent(id="gshell-builtins:source", description="Load a file/url into the current shell")
public class SourceCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Requirement
private CommandLineExecutor executor;
@Argument(required=true, description="Source file")
private String source;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
URL url;
try {
@@ -77,7 +80,7 @@
IOUtil.close(reader);
}
- return SUCCESS;
+ return Result.SUCCESS;
}
private BufferedReader openReader(final Object source) throws IOException {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java Fri Jun 20 03:51:18 2008
@@ -19,14 +19,17 @@
package org.apache.geronimo.gshell.commands.builtins;
-import java.util.List;
-
import org.apache.geronimo.gshell.application.DefaultVariables;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
/**
* Unset a variable or property.
@@ -35,8 +38,10 @@
*/
@CommandComponent(id="gshell-builtins:unset", description="Unset a variable")
public class UnsetCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
enum Mode
{
VARIABLE,
@@ -46,10 +51,15 @@
@Option(name="-m", aliases={"--mode"}, description="Unset mode")
private Mode mode = Mode.VARIABLE;
+ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
@Argument(required=true, description="Variable name")
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ Variables variables = context.getVariables();
+
for (String arg : args) {
String namevalue = String.valueOf(arg);
@@ -59,12 +69,12 @@
break;
case VARIABLE:
- unsetVariable(namevalue);
+ unsetVariable(variables, namevalue);
break;
}
}
- return SUCCESS;
+ return Result.SUCCESS;
}
private void ensureIsIdentifier(final String name) {
@@ -81,14 +91,12 @@
System.getProperties().remove(name);
}
- private void unsetVariable(final String name) {
+ private void unsetVariable(final Variables vars, final String name) {
log.info("Unsetting variable: {}", name);
ensureIsIdentifier(name);
// Command vars always has a parent, set only makes sence when setting in parent's scope
- Variables vars = variables.parent();
-
- vars.unset(name);
+ vars.parent().unset(name);
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java Fri Jun 20 03:51:18 2008
@@ -19,22 +19,21 @@
package org.apache.geronimo.gshell.commands.optional;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
/**
* Concatenate and print files and/or URLs.
@@ -43,15 +42,22 @@
*/
@CommandComponent(id="gshell-optional:cat", description="Concatenate and print files and/or URLs.")
public class CatCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Option(name="-n", description="Number the output lines, starting at 1")
private boolean displayLineNumbers;
+ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
@Argument(description="File or URL", required=true)
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+
//
// Support "-" if length is one, and read from io.in
// This will help test command pipelines.
@@ -86,7 +92,7 @@
}
}
- return SUCCESS;
+ return Result.SUCCESS;
}
private void cat(final BufferedReader reader, final IO io) throws IOException {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java Fri Jun 20 03:51:18 2008
@@ -19,12 +19,16 @@
package org.apache.geronimo.gshell.commands.optional;
-import java.util.List;
-
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.io.PumpStreamHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
/**
* Execute system processes.
@@ -33,14 +37,20 @@
*/
@CommandComponent(id="gshell-optional:exec", description="Execute system processes")
public class ExecuteCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
private ProcessBuilder builder;
@Argument(description="Argument", required=true)
private List<String> args;
-
- protected Object doExecute() throws Exception {
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+
assert builder != null;
log.info("Executing: {}", builder.command());
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java Fri Jun 20 03:51:18 2008
@@ -19,14 +19,17 @@
package org.apache.geronimo.gshell.commands.optional;
-import java.lang.reflect.Method;
-import java.util.List;
-
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.util.Arguments;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Method;
+import java.util.List;
/**
* Execute a Java standard application.
@@ -39,8 +42,10 @@
*/
@CommandComponent(id="gshell-optional:java", description="Execute a Java standard application")
public class JavaCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Option(name="-m", aliases={"--method"}, metaVar="METHOD", description="Invoke a named method")
private String methodName = "main";
@@ -50,7 +55,9 @@
@Argument(index=1, metaVar="ARG", description="Arguments to pass to the METHOD of CLASSNAME")
private List<String> args;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
boolean info = log.isInfoEnabled();
Class type = Thread.currentThread().getContextClassLoader().loadClass(className);
@@ -73,6 +80,6 @@
log.info("Result: " + result);
}
- return SUCCESS;
+ return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java Fri Jun 20 03:51:18 2008
@@ -20,8 +20,11 @@
package org.apache.geronimo.gshell.commands.optional;
import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Sleep... zzzZ
@@ -30,12 +33,16 @@
*/
@CommandComponent(id="gshell-optional:sleep", description="Sleep for a bit then wake up")
public class SleepCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Argument(description="Time in milliseconds", required=true)
private int time = -1;
-
- protected Object doExecute() throws Exception {
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
log.info("Sleeping for " + time);
try {
@@ -47,6 +54,6 @@
log.info("Awake now");
- return SUCCESS;
+ return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java Fri Jun 20 03:51:18 2008
@@ -19,8 +19,11 @@
package org.apache.geronimo.gshell.commands.optional;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
//
// HACK: This is a temporary to handle shells which need to keep around after running
@@ -34,15 +37,19 @@
*/
@CommandComponent(id="gshell-optional:wait", description="Wait, blocking execution... not nice")
public class WaitCommand
- extends CommandSupport
+ implements CommandAction
{
- protected Object doExecute() throws Exception {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
log.info("Waiting...");
synchronized (this) {
wait();
}
- return SUCCESS;
+ return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/java/org/apache/geronimo/gshell/commands/repository/ResolveCommand.java Fri Jun 20 03:51:18 2008
@@ -21,14 +21,18 @@
import org.apache.geronimo.gshell.artifact.ArtifactManager;
import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Set;
@@ -40,8 +44,10 @@
*/
@CommandComponent(id="gshell-repository:resolve", description="Resolve repository artifacts")
public class ResolveCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Requirement
private ArtifactManager artifactManager;
@@ -67,7 +73,9 @@
@Option(name="-T", aliases={"--transitive"}, description="Resolve transitive dependencies")
private boolean transitive;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
assert artifactManager != null;
ArtifactFactory factory = artifactManager.getArtifactFactory();
@@ -76,6 +84,8 @@
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+ IO io = context.getIo();
+
//
// TODO: Update the AM API to use this as originating when artifact == null and artifact dependencies != null
//
@@ -107,6 +117,6 @@
// TODO: Do something with the result?
//
- return SUCCESS;
+ return Result.SUCCESS;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java Fri Jun 20 03:51:18 2008
@@ -24,6 +24,9 @@
import org.apache.commons.vfs.FileUtil;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Copy files.
@@ -34,13 +37,16 @@
public class CopyCommand
extends VFSCommandSupport
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Argument(index=0, required=true, description="Source")
private String sourceName;
@Argument(index=1, required=true, description="Target")
private String targetName;
-
- protected Object doExecute() throws Exception {
+public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
FileSystemManager fsm = getFileSystemManager();
FileObject source = fsm.resolveFile(sourceName);
FileObject target = fsm.resolveFile(targetName);
@@ -49,6 +55,6 @@
FileUtil.copyContent(source, target);
- return SUCCESS;
+ return Result.SUCCESS;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java Fri Jun 20 03:51:18 2008
@@ -22,7 +22,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.VFS;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.CommandAction;
/**
* Support for VFS commands.
@@ -30,7 +30,7 @@
* @version $Rev$ $Date$
*/
public abstract class VFSCommandSupport
- extends CommandSupport
+ implements CommandAction
{
private FileSystemManager fsManager;
Copied: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandActionDescriptor.java (from r669210, geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandActionDescriptor.java?p2=geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandActionDescriptor.java&p1=geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java&r1=669210&r2=669849&rev=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java (original)
+++ geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandActionDescriptor.java Fri Jun 20 03:51:18 2008
@@ -19,32 +19,32 @@
package org.apache.geronimo.gshell.plugin.descriptor;
-import org.apache.geronimo.gshell.yarn.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
+import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.model.command.CommandModel;
import org.apache.geronimo.gshell.model.command.Parameter;
import org.apache.geronimo.gshell.model.command.Requirement;
-import org.apache.geronimo.gshell.command.Executable;
+import org.apache.geronimo.gshell.yarn.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.yarn.ToStringStyle;
import org.codehaus.plexus.component.repository.ComponentRequirement;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
/**
- * Descriptor for a GShell command's plexus component.
+ * Descriptor for a GShell command action's plexus component.
*
* @version $Rev$ $Date$
*/
-public class CommandDescriptor
+public class CommandActionDescriptor
extends ComponentDescriptorSupport
{
private final CommandModel model;
- public CommandDescriptor(final CommandModel model) {
+ public CommandActionDescriptor(final CommandModel model) {
assert model != null;
this.model = model;
setDescription(model.getDescription());
- setRole(Executable.class);
+ setRole(CommandAction.class);
setRoleHint(model.getId());
setImplementation(model.getImplementation());
setVersion(model.getVersion());
Modified: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/PluginDescriptor.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/PluginDescriptor.java (original)
+++ geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/PluginDescriptor.java Fri Jun 20 03:51:18 2008
@@ -52,8 +52,8 @@
private void addCommand(final CommandModel model) {
assert model != null;
+ addComponentDescriptor(new CommandActionDescriptor(model));
addComponentDescriptor(new CommandContainerDescriptor(model));
- addComponentDescriptor(new CommandDescriptor(model));
}
public void addComponentDescriptor(final ComponentDescriptor descriptor) {
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java Fri Jun 20 03:51:18 2008
@@ -23,13 +23,13 @@
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.clp.Printer;
import org.apache.geronimo.gshell.clp.ProcessingException;
+import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContainer;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.CommandInfo;
-import org.apache.geronimo.gshell.command.Executable;
-import org.apache.geronimo.gshell.util.Arguments;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
+import org.apache.geronimo.gshell.util.Arguments;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Configuration;
@@ -53,7 +53,7 @@
private GShellPlexusContainer container;
- @Configuration("invalid") // Just to mark what this is used for, since we have to configure a default value
+ @Configuration("") // Just to mark what this is used for, since we have to configure a default value
private String commandId;
// Contextualizable
@@ -67,49 +67,50 @@
log.debug("Container: {}", container);
}
- // CommandContainer
-
- public Executable getExecutable() {
+ private CommandAction getAction() {
assert container != null;
try {
- return container.lookupComponent(Executable.class, commandId);
+ return container.lookupComponent(CommandAction.class, commandId);
}
catch (ComponentLookupException e) {
throw new RuntimeException(e);
}
}
- public Object execute(final CommandContext context, final Object... args) throws Exception {
+ // CommandContainer
+
+ public Object execute(final CommandContext context) throws Exception {
assert context != null;
- assert args != null;
- log.trace("Executing; context={}, args={}", context, args);
+ log.trace("Executing; context={}");
- Executable executable = getExecutable();
+ CommandAction action = getAction();
// TODO: Handle logging muck
+ // NOTE: For logging, just set the NDC/MDC and let the loggers name be whatever the command set it to be.
// TODO: Bind context, io and variables
+ // NOTE: No, no no...
// Process command line options/arguments, return if we have been asked to display --help
- if (processArguments(context, executable, args)) {
- return Executable.Result.SUCCESS;
+ if (processArguments(context, action, context.getArguments())) {
+ return CommandAction.Result.SUCCESS;
}
- Object result = executable.execute(context, args);
+ Object result = action.execute(context);
log.trace("Result: {}", result);
return result;
}
- private boolean processArguments(final CommandContext context, final Executable executable, final Object... args) throws ProcessingException {
+ private boolean processArguments(final CommandContext context, final CommandAction action, final Object[] args) throws ProcessingException {
assert context != null;
assert args != null;
CommandLineProcessor clp = new CommandLineProcessor();
- clp.addBean(executable);
+ clp.addBean(action);
// Attach some help context
HelpSupport help = new HelpSupport();
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java Fri Jun 20 03:51:18 2008
@@ -21,13 +21,13 @@
import org.apache.geronimo.gshell.command.CommandContainer;
import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineBuilder.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineBuilder.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineBuilder.java Fri Jun 20 03:51:18 2008
@@ -20,15 +20,14 @@
package org.apache.geronimo.gshell.rapture;
import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.commandline.CommandLine;
+import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.rapture.LoggingVisitor;
import org.apache.geronimo.gshell.notification.ErrorNotification;
import org.apache.geronimo.gshell.parser.ASTCommandLine;
import org.apache.geronimo.gshell.parser.CommandLineParser;
import org.apache.geronimo.gshell.parser.ParseException;
import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.commandline.CommandLine;
-import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandLineExecutor.java Fri Jun 20 03:51:18 2008
@@ -21,13 +21,15 @@
import org.apache.geronimo.gshell.application.ApplicationManager;
import org.apache.geronimo.gshell.application.DefaultVariables;
+import org.apache.geronimo.gshell.chronos.StopWatch;
import org.apache.geronimo.gshell.command.CommandContainer;
import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.command.CommandInfo;
import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.util.Arguments;
-import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.commandline.CommandExecutionFailied;
+import org.apache.geronimo.gshell.commandline.CommandLine;
+import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
+import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.io.SystemOutputHijacker;
import org.apache.geronimo.gshell.layout.LayoutManager;
@@ -35,12 +37,10 @@
import org.apache.geronimo.gshell.model.layout.AliasNode;
import org.apache.geronimo.gshell.model.layout.CommandNode;
import org.apache.geronimo.gshell.model.layout.Node;
-import org.apache.geronimo.gshell.shell.Environment;
import org.apache.geronimo.gshell.notification.ErrorNotification;
-import org.apache.geronimo.gshell.chronos.StopWatch;
-import org.apache.geronimo.gshell.commandline.CommandLine;
-import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
-import org.apache.geronimo.gshell.commandline.CommandExecutionFailied;
+import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.util.Arguments;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -252,6 +252,10 @@
CommandInfo info;
+ public Object[] getArguments() {
+ return args;
+ }
+
public IO getIo() {
return io;
}
@@ -306,7 +310,7 @@
Object result;
try {
- result = container.execute(context, args);
+ result = container.execute(context);
log.debug("Command completed with result: {}, after: {}", result, watch);
}
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultLayoutManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultLayoutManager.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultLayoutManager.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultLayoutManager.java Fri Jun 20 03:51:18 2008
@@ -20,11 +20,11 @@
package org.apache.geronimo.gshell.rapture;
import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.layout.LayoutManager;
+import org.apache.geronimo.gshell.layout.NotFoundException;
import org.apache.geronimo.gshell.model.layout.GroupNode;
import org.apache.geronimo.gshell.model.layout.Layout;
import org.apache.geronimo.gshell.model.layout.Node;
-import org.apache.geronimo.gshell.layout.LayoutManager;
-import org.apache.geronimo.gshell.layout.NotFoundException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.slf4j.Logger;
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultShell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultShell.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultShell.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultShell.java Fri Jun 20 03:51:18 2008
@@ -30,11 +30,11 @@
import org.apache.geronimo.gshell.console.JLineConsole;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.model.application.Branding;
+import org.apache.geronimo.gshell.notification.ErrorNotification;
+import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.shell.Environment;
import org.apache.geronimo.gshell.shell.Shell;
import org.apache.geronimo.gshell.shell.ShellInfo;
-import org.apache.geronimo.gshell.notification.ExitNotification;
-import org.apache.geronimo.gshell.notification.ErrorNotification;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/ExecutingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/ExecutingVisitor.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/ExecutingVisitor.java (original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/ExecutingVisitor.java Fri Jun 20 03:51:18 2008
@@ -20,7 +20,7 @@
package org.apache.geronimo.gshell.rapture;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.util.Arguments;
+import org.apache.geronimo.gshell.notification.ErrorNotification;
import org.apache.geronimo.gshell.parser.ASTCommandLine;
import org.apache.geronimo.gshell.parser.ASTExpression;
import org.apache.geronimo.gshell.parser.ASTOpaqueString;
@@ -30,7 +30,7 @@
import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
import org.apache.geronimo.gshell.parser.SimpleNode;
import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.notification.ErrorNotification;
+import org.apache.geronimo.gshell.util.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java Fri Jun 20 03:51:18 2008
@@ -19,14 +19,18 @@
package org.apache.geronimo.gshell.remote.client;
-import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.io.PromptReader;
+import org.apache.geronimo.gshell.notification.ExitNotification;
import org.apache.geronimo.gshell.remote.client.proxy.RemoteShellProxy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.net.URI;
import java.util.ArrayList;
@@ -39,8 +43,10 @@
*/
@CommandComponent(id="gshell-remote:rsh", description="Connect to a remote GShell server")
public class RshCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Option(name="-b", aliases={"--bind"}, metaVar="URI", description="Bind local address to URI")
private URI local;
@@ -62,7 +68,11 @@
@Requirement
private RshClient client;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
+ IO io = context.getIo();
+
io.info("Connecting to: {}", remote);
client.connect(remote, local);
@@ -91,7 +101,7 @@
RemoteShellProxy shell = new RemoteShellProxy(client, io);
- Object rv = SUCCESS;
+ Object rv = Result.SUCCESS;
try {
shell.run(command.toArray());
Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java?rev=669849&r1=669848&r2=669849&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerCommand.java Fri Jun 20 03:51:18 2008
@@ -19,13 +19,17 @@
package org.apache.geronimo.gshell.remote.server;
-import java.net.URI;
-
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.annotation.CommandComponent;
import org.apache.geronimo.gshell.command.annotation.Requirement;
-import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.io.IO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
/**
* Command to start a remote shell server.
@@ -34,8 +38,10 @@
*/
@CommandComponent(id="gshell-remote:rsh-server", description="Start a GShell server")
public class RshServerCommand
- extends CommandSupport
+ implements CommandAction
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
@Option(name="-b", aliases={ "--background" }, description="Run in background")
private boolean background;
@@ -45,9 +51,13 @@
@Requirement
private RshServer server;
- protected Object doExecute() throws Exception {
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+
server.bind(location);
+ IO io = context.getIo();
+
io.info("Listening on: {}", location);
if (!background) {
@@ -58,6 +68,6 @@
server.close();
}
- return SUCCESS;
+ return Result.SUCCESS;
}
}
\ No newline at end of file