geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r697800 - in /geronimo/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/a...
Date Mon, 22 Sep 2008 12:59:11 GMT
Author: jdillon
Date: Mon Sep 22 05:59:10 2008
New Revision: 697800

URL: http://svn.apache.org/viewvc?rev=697800&view=rev
Log:
Using ShellContext for Command.execute()
Moved variable nesting into Command impl
Renamed CommandImpl to StatelessCommand

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
  (contents, props changed)
      - copied, changed from r697742, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
Removed:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
Modified:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Alias.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Group.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml

Modified: 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=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
(original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
Mon Sep 22 05:59:10 2008
@@ -21,6 +21,7 @@
 
 import org.apache.geronimo.gshell.i18n.MessageSource;
 import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.shell.ShellContext;
 
 /**
  * Provides facilites for a configured command instance.
@@ -66,11 +67,10 @@
 
     /**
      * Executes the commands configured action.
-     * 
-     * @param args          The arguments to the command; must not be null.
-     * @param io            The I/O context for the command; must not be null.
-     * @param variables     The environment variables for the command; must not be null.
-     * @return              The command result; never null
+     *
+     * @param context   The executing shell's context.
+     * @param args      The arguments to the command; must not be null.
+     * @return          The command result; never null
      */
-    CommandResult execute(Object[] args, IO io, Variables variables);
+    CommandResult execute(ShellContext context, Object[] args);
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Alias.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Alias.java?rev=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Alias.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Alias.java
Mon Sep 22 05:59:10 2008
@@ -20,15 +20,12 @@
 package org.apache.geronimo.gshell.wisdom.command;
 
 import org.apache.geronimo.gshell.command.CommandResult;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.shell.ShellContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.PostConstruct;
-
 /**
- * ???
+ * Alias {@link org.apache.geronimo.gshell.command.Command} component.
  *
  * @version $Rev$ $Date$
  */
@@ -37,13 +34,12 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @SuppressWarnings({"UnusedDeclaration"})
-    @PostConstruct
-    private void init() {
-        // TODO: setup action, documenter, completer, messages
-    }
+    public CommandResult execute(final ShellContext context, final Object[] args) {
+        assert context != null;
+        assert args != null;
+
+        log.debug("Executing");
 
-    public CommandResult execute(final Object[] args, final IO io, final Variables variables)
{
-        return null;
+        throw new Error("not implemented");
     }
 }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java?rev=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
Mon Sep 22 05:59:10 2008
@@ -114,7 +114,7 @@
         CommandLineProcessor clp = new CommandLineProcessor();
         
         // Attach our helper to inject --help
-        CommandImpl.HelpSupport help = new CommandImpl.HelpSupport();
+        StatelessCommand.HelpSupport help = new StatelessCommand.HelpSupport();
         clp.addBean(help);
 
         // And then the beans options

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Group.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Group.java?rev=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Group.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/Group.java
Mon Sep 22 05:59:10 2008
@@ -20,15 +20,12 @@
 package org.apache.geronimo.gshell.wisdom.command;
 
 import org.apache.geronimo.gshell.command.CommandResult;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.shell.ShellContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.PostConstruct;
-
 /**
- * ???
+ * Group {@link org.apache.geronimo.gshell.command.Command} component.
  *
  * @version $Rev$ $Date$
  */
@@ -37,13 +34,12 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @SuppressWarnings({"UnusedDeclaration"})
-    @PostConstruct
-    private void init() {
-        // TODO: setup action, documenter, completer, messages
-    }
+    public CommandResult execute(final ShellContext context, final Object[] args) {
+        assert context != null;
+        assert args != null;
 
-    public CommandResult execute(final Object[] args, final IO io, final Variables variables)
{
-        return null;
+        log.debug("Executing");
+        
+        throw new Error("not implemented");
     }
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
(from r697742, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java&r1=697742&r2=697800&rev=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
Mon Sep 22 05:59:10 2008
@@ -32,16 +32,17 @@
 import org.apache.geronimo.gshell.notification.Notification;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.geronimo.gshell.shell.ShellContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
 
 /**
- * The default {@link Command} component.
+ * Stateless {@link org.apache.geronimo.gshell.command.Command} component.
  *
  * @version $Rev$ $Date$
  */
-public class CommandImpl
+public class StatelessCommand
     extends CommandSupport
     implements BeanContainerAware
 {
@@ -55,10 +56,9 @@
         this.container = container;
     }
 
-    public CommandResult execute(final Object[] args, final IO io, final Variables variables)
{
+    public CommandResult execute(final ShellContext context, final Object[] args) {
+        assert context != null;
         assert args != null;
-        assert io != null;
-        assert variables != null;
 
         log.trace("Executing");
 
@@ -72,6 +72,7 @@
         CommandResult result;
 
         try {
+            final IO io = context.getIo();
             CommandAction action = getAction();
 
             // Setup the command action
@@ -89,7 +90,9 @@
             }
 
             // Setup the command context
-            CommandContext context = new CommandContext() {
+            CommandContext ctx = new CommandContext() {
+                private final Variables variables = new Variables(context.getVariables());
+
                 public Object[] getArguments() {
                     return args;
                 }
@@ -103,7 +106,7 @@
                 }
 
                 public Command getCommand() {
-                    return CommandImpl.this;
+                    return StatelessCommand.this;
                 }
             };
 
@@ -111,7 +114,7 @@
             try {
                 log.trace("Executing action: {}", action);
 
-                Object value = action.execute(context);
+                Object value = action.execute(ctx);
 
                 log.trace("Result: {}", value);
 

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java?rev=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
Mon Sep 22 05:59:10 2008
@@ -212,15 +212,12 @@
 
         log.debug("Executing");
 
-        IO io = context.getIo();
+        // Locate the command
         Variables variables = context.getVariables();
-
         Command command = commandResolver.resolve(variables, path);
 
-        // Instances get their own namespace with defaults from the current
-        Variables vars = new Variables(variables);
-
         // Hijack the system streams in the current thread's context
+        IO io = context.getIo();
         SystemOutputHijacker.register(io.outputStream, io.errorStream);
 
         // Setup command timings
@@ -228,7 +225,7 @@
         
         CommandResult result;
         try {
-            result = command.execute(args, io, vars);
+            result = command.execute(context, args);
 
             log.debug("Command completed with result: {}, after: {}", result, watch);
         }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=697800&r1=697799&r2=697800&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
Mon Sep 22 05:59:10 2008
@@ -43,7 +43,7 @@
 
     <bean id="shell" class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl"/>
 
-    <bean id="commandTemplate" class="org.apache.geronimo.gshell.wisdom.command.CommandImpl"
abstract="true">
+    <bean id="commandTemplate" class="org.apache.geronimo.gshell.wisdom.command.StatelessCommand"
abstract="true">
         <property name="documenter">
             <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
         </property>



Mime
View raw message