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/10/08 14:24:08 UTC

svn commit: r702825 - in /geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell: command/ notification/ registry/

Author: jdillon
Date: Wed Oct  8 05:24:08 2008
New Revision: 702825

URL: http://svn.apache.org/viewvc?rev=702825&view=rev
Log:
Added ResultNotification, made SuccessNotification and FailureNotification extend from it

Added:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/ResultNotification.java
      - copied, changed from r702494, geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java
Modified:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/SuccessNotification.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java

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=702825&r1=702824&r2=702825&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 Wed Oct  8 05:24:08 2008
@@ -20,7 +20,6 @@
 package org.apache.geronimo.gshell.command;
 
 import org.apache.geronimo.gshell.i18n.MessageSource;
-import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.shell.ShellContext;
 
 /**
@@ -30,6 +29,8 @@
  */
 public interface Command
 {
+    // TODO: Add getName():String or getLocation():CommandLocation
+
     /**
      * Returns the action of the command.
      *

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java?rev=702825&r1=702824&r2=702825&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java Wed Oct  8 05:24:08 2008
@@ -97,6 +97,13 @@
         return value;
     }
 
+    @SuppressWarnings({"unchecked"})
+    public <T> T get(final String name, final Class<T> type) {
+        assert type != null;
+
+        return (T)get(name);
+    }
+    
     public Object get(final String name, final Object _default) {
         Object value = get(name);
         if (value == null) {
@@ -199,8 +206,6 @@
     public class ImmutableVariableException
         extends RuntimeException
     {
-        ///CLOVER:OFF
-
         public ImmutableVariableException(final String name) {
             super("Variable is immutable: " + name);
         }

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java?rev=702825&r1=702824&r2=702825&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java Wed Oct  8 05:24:08 2008
@@ -29,24 +29,16 @@
  *
  * @version $Rev$ $Date$
  */
-public final class FailureNotification
-    extends Notification
+public class FailureNotification
+    extends ResultNotification
 {
     private static final long serialVersionUID = 1;
 
     public FailureNotification(final String msg) {
-        super(msg);
-    }
-
-    public FailureNotification(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-
-    public FailureNotification(final Throwable cause) {
-        super(cause);
+        super(msg, Result.FAILURE);
     }
 
     public FailureNotification() {
-        super();
+        super(Result.FAILURE);
     }
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/ResultNotification.java (from r702494, geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/ResultNotification.java?p2=geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/ResultNotification.java&p1=geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java&r1=702494&r2=702825&rev=702825&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/FailureNotification.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/ResultNotification.java Wed Oct  8 05:24:08 2008
@@ -19,34 +19,31 @@
 
 package org.apache.geronimo.gshell.notification;
 
-import org.apache.geronimo.gshell.command.CommandAction.Result;
-
 /**
- * Thrown to indicate a command failure state.
- *
- * Use of this notification won't cause an error to be propagated
- * only some details logged and the {@link Result#FAILURE} returned.
+ * Thrown to indicate a command result state.
  *
  * @version $Rev$ $Date$
  */
-public final class FailureNotification
+public class ResultNotification
     extends Notification
 {
     private static final long serialVersionUID = 1;
 
-    public FailureNotification(final String msg) {
-        super(msg);
-    }
+    private final Object result;
 
-    public FailureNotification(final String msg, final Throwable cause) {
-        super(msg, cause);
+    public ResultNotification(final Object result) {
+        super();
+
+        this.result = result;
     }
 
-    public FailureNotification(final Throwable cause) {
-        super(cause);
+    public ResultNotification(final String msg, final Object result) {
+        super(msg);
+
+        this.result = result;
     }
 
-    public FailureNotification() {
-        super();
+    public Object getResult() {
+        return result;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/SuccessNotification.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/SuccessNotification.java?rev=702825&r1=702824&r2=702825&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/SuccessNotification.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/notification/SuccessNotification.java Wed Oct  8 05:24:08 2008
@@ -29,24 +29,16 @@
  *
  * @version $Rev$ $Date$
  */
-public final class SuccessNotification
-    extends Notification
+public class SuccessNotification
+    extends ResultNotification
 {
     private static final long serialVersionUID = 1;
 
     public SuccessNotification(final String msg) {
-        super(msg);
-    }
-
-    public SuccessNotification(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-
-    public SuccessNotification(final Throwable cause) {
-        super(cause);
+        super(msg, Result.SUCCESS);
     }
 
     public SuccessNotification() {
-        super();
+        super(Result.SUCCESS);
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java?rev=702825&r1=702824&r2=702825&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java Wed Oct  8 05:24:08 2008
@@ -20,8 +20,8 @@
 package org.apache.geronimo.gshell.registry;
 
 import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.command.CommandException;
+import org.apache.geronimo.gshell.command.Variables;
 
 import java.util.Collection;
 
@@ -32,7 +32,13 @@
  */
 public interface CommandResolver
 {
-    Command resolveCommand(Variables variables, String path) throws CommandException;
+    String PATH = "gshell.path";
+
+    String PATH_SEPARATOR = ":";
+
+    String GROUP = "gshell.group";
+
+    Command resolveCommand(String name, Variables variables) throws CommandException;
 
-    Collection<Command> resolveCommands(Variables variables, String path) throws CommandException;
+    Collection<Command> resolveCommands(String name, Variables variables) throws CommandException;
 }
\ No newline at end of file