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/09/22 15:30:48 UTC

svn commit: r697819 - in /geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command: CommandSupport.java StatelessCommand.java

Author: jdillon
Date: Mon Sep 22 06:30:47 2008
New Revision: 697819

URL: http://svn.apache.org/viewvc?rev=697819&view=rev
Log:
Changed asserts to hard ITE when state is not as expected
Changed CommandSupport setters to be protected, expose publics as needed to expose mutability

Modified:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java?rev=697819&r1=697818&r2=697819&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java Mon Sep 22 06:30:47 2008
@@ -45,7 +45,9 @@
     private MessageSource messages;
 
     public String getId() {
-        assert id != null;
+        if (id == null) {
+            throw new IllegalStateException("Missing required property: id");
+        }
 
         return id;
     }
@@ -57,12 +59,14 @@
     }
 
     public CommandAction getAction() {
-        assert action != null;
+        if (action == null) {
+            throw new IllegalStateException("Missing required property: action");
+        }
 
         return action;
     }
 
-    public void setAction(final CommandAction action) {
+    protected void setAction(final CommandAction action) {
         assert action != null;
 
         handleCommandAware(action);
@@ -71,12 +75,14 @@
     }
 
     public CommandDocumenter getDocumenter() {
-        assert documenter != null;
+        if (documenter == null) {
+            throw new IllegalStateException("Missing required property: documenter");
+        }
 
         return documenter;
     }
 
-    public void setDocumenter(final CommandDocumenter documenter) {
+    protected void setDocumenter(final CommandDocumenter documenter) {
         assert documenter != null;
 
         handleCommandAware(documenter);
@@ -85,12 +91,14 @@
     }
 
     public CommandCompleter getCompleter() {
-        assert completer != null;
+        if (completer == null) {
+            throw new IllegalStateException("Missing required property: completer");
+        }
         
         return completer;
     }
 
-    public void setCompleter(final CommandCompleter completer) {
+    protected void setCompleter(final CommandCompleter completer) {
         assert completer != null;
 
         handleCommandAware(completer);
@@ -99,12 +107,14 @@
     }
 
     public MessageSource getMessages() {
-        assert messages != null;
+        if (messages == null) {
+            throw new IllegalStateException("Missing required property: messages");
+        }
 
         return messages;
     }
 
-    public void setMessages(final MessageSource messages) {
+    protected void setMessages(final MessageSource messages) {
         assert messages != null;
 
         handleCommandAware(messages);

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.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?rev=697819&r1=697818&r2=697819&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java Mon Sep 22 06:30:47 2008
@@ -28,11 +28,13 @@
 import org.apache.geronimo.gshell.command.CommandDocumenter;
 import org.apache.geronimo.gshell.command.CommandResult;
 import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.CommandCompleter;
 import org.apache.geronimo.gshell.io.IO;
 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.apache.geronimo.gshell.i18n.MessageSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
@@ -56,6 +58,28 @@
         this.container = container;
     }
 
+    // Expose some of our super-classes properties for spring configuration
+
+    @Override
+    public void setAction(final CommandAction action) {
+        super.setAction(action);
+    }
+
+    @Override
+    public void setDocumenter(final CommandDocumenter documenter) {
+        super.setDocumenter(documenter);
+    }
+
+    @Override
+    public void setCompleter(final CommandCompleter completer) {
+        super.setCompleter(completer);
+    }
+
+    @Override
+    public void setMessages(final MessageSource messages) {
+        super.setMessages(messages);
+    }
+
     public CommandResult execute(final ShellContext context, final Object[] args) {
         assert context != null;
         assert args != null;