geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r694284 - in /geronimo/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/ gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/ gshell...
Date Thu, 11 Sep 2008 14:57:17 GMT
Author: jdillon
Date: Thu Sep 11 07:57:14 2008
New Revision: 694284

URL: http://svn.apache.org/viewvc?rev=694284&view=rev
Log:
Get some basic commands working again

Added:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java
  (contents, props changed)
      - copied, changed from r694267, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
Removed:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/
Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerImpl.java

Copied: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java
(from r694267, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java?p2=geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java&r1=694267&r2=694284&rev=694284&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java
Thu Sep 11 07:57:14 2008
@@ -17,47 +17,14 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.wisdom.command;
-
-import org.apache.geronimo.gshell.command.CommandContainer;
-import org.apache.geronimo.gshell.command.CommandContainerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.apache.geronimo.gshell.command;
 
 /**
- * Default implementation of a {@link CommandContainerFactory} component.
+ * Provides registration facilities for {@link CommandContainer} instances.
  *
  * @version $Rev$ $Date$
  */
-public class CommandContainerFactoryImpl
-    implements CommandContainerFactory
+public interface CommandContainerRegistry
 {
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    public CommandContainer create(final String id) throws Exception {
-        assert id != null;
-
-        log.debug("Locating container for ID: {}", id);
-
-        /*
-        ComponentDescriptor descriptor = container.getComponentDescriptor(CommandContainer.class,
id);
-        if (descriptor == null) {
-            // TODO: Throw typed exception
-            throw new Exception("Command container not found for ID: " + id);
-        }
-
-        CommandContainer command;
-        try {
-            command = container.lookupComponent(CommandContainer.class, id);
-        }
-        catch (ComponentLookupException e) {
-            // TODO: Throw typed exception
-            throw new Exception("Failed to access command container for ID: " + id, e);
-        }
-
-        return command;
-        */
-
-        return null;
-    }
+    void register(CommandContainer commandContainer);
 }
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainerRegistry.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

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

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml?rev=694284&r1=694283&r2=694284&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml
Thu Sep 11 07:57:14 2008
@@ -31,6 +31,48 @@
 
     <context:annotation-config/>
 
-    <!-- TODO: -->
+    <!-- TODO: Need CommandContainerAware interface for all components -->
+
+    <bean class="org.apache.geronimo.gshell.wisdom.command.CommandContainerImpl">
+        <property name="id" value="gshell-builtins:echo"/>
+
+        <property name="action">
+            <bean class="org.apache.geronimo.gshell.commands.builtins.EchoCommand"/>
+        </property>
+
+        <property name="completer">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandCompleterImpl"/>
+        </property>
+
+        <property name="documenter">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl">
+                <!--
+                <property name="name" value="echo"/>
+                <property name="description" value="Blah, blah, blah"/>
+                -->
+            </bean>
+        </property>
+    </bean>
+
+    <bean class="org.apache.geronimo.gshell.wisdom.command.CommandContainerImpl">
+        <property name="id" value="gshell-builtins:exit"/>
+
+        <property name="action">
+            <bean class="org.apache.geronimo.gshell.commands.builtins.ExitCommand"/>
+        </property>
+
+        <property name="completer">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandCompleterImpl"/>
+        </property>
+
+        <property name="documenter">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl">
+                <!--
+                <property name="name" value="echo"/>
+                <property name="description" value="Blah, blah, blah"/>
+                -->
+            </bean>
+        </property>
+    </bean>
 
 </beans>
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java?rev=694284&r1=694283&r2=694284&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerFactoryImpl.java
Thu Sep 11 07:57:14 2008
@@ -21,43 +21,50 @@
 
 import org.apache.geronimo.gshell.command.CommandContainer;
 import org.apache.geronimo.gshell.command.CommandContainerFactory;
+import org.apache.geronimo.gshell.command.CommandContainerRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Map;
+import java.util.HashMap;
+
 /**
- * Default implementation of a {@link CommandContainerFactory} component.
+ * Default implementation of a {@link CommandContainerFactory} and {@link CommandContainerRegistry}
components.
  *
  * @version $Rev$ $Date$
  */
 public class CommandContainerFactoryImpl
-    implements CommandContainerFactory
+    implements CommandContainerRegistry, CommandContainerFactory
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    // CommandContainerRegistry
+
+    private Map<String,CommandContainer> registrations = new HashMap<String,CommandContainer>();
+
+    public void register(final CommandContainer commandContainer) {
+        assert commandContainer != null;
+
+        String id = commandContainer.getId();
+
+        log.debug("Registering command container: {}", id);
+        
+        registrations.put(id, commandContainer);
+    }
+
+    // CommandContainerFactory
+
     public CommandContainer create(final String id) throws Exception {
         assert id != null;
 
         log.debug("Locating container for ID: {}", id);
 
-        /*
-        ComponentDescriptor descriptor = container.getComponentDescriptor(CommandContainer.class,
id);
-        if (descriptor == null) {
-            // TODO: Throw typed exception
-            throw new Exception("Command container not found for ID: " + id);
-        }
+        CommandContainer commandContainer = registrations.get(id);
 
-        CommandContainer command;
-        try {
-            command = container.lookupComponent(CommandContainer.class, id);
+        if (commandContainer == null) {
+            throw new RuntimeException("No command container registered for id: " + id);
         }
-        catch (ComponentLookupException e) {
-            // TODO: Throw typed exception
-            throw new Exception("Failed to access command container for ID: " + id, e);
-        }
-
-        return command;
-        */
 
-        return null;
+        return commandContainer;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerImpl.java?rev=694284&r1=694283&r2=694284&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerImpl.java
Thu Sep 11 07:57:14 2008
@@ -29,10 +29,12 @@
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.command.CommandDocumenter;
 import org.apache.geronimo.gshell.command.CommandResult;
+import org.apache.geronimo.gshell.command.CommandContainerRegistry;
 import org.apache.geronimo.gshell.notification.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.annotation.PostConstruct;
 
@@ -46,6 +48,9 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    @Autowired
+    private CommandContainerRegistry registry;
+
     private String id;
 
     private CommandAction action;
@@ -79,7 +84,7 @@
     }
 
     public void setDocumenter(final CommandDocumenter documenter) {
-        // documenter could be null
+        assert documenter != null;
 
         this.documenter = documenter;
     }
@@ -89,7 +94,7 @@
     }
 
     public void setCompleter(final CommandCompleter completer) {
-        // completer could be null
+        assert completer != null;
         
         this.completer = completer;
     }
@@ -97,7 +102,14 @@
     @PostConstruct
     public void init() {
         // TODO: Validate properties
+        
+        assert registry != null;
+        assert id != null;
+        assert action != null;
+
         // TODO: Inject ourself into CommandContainerAware instances
+
+        registry.register(this);
     }
     
     public CommandResult execute(final CommandContext context) {
@@ -159,6 +171,7 @@
      */
     private boolean processArguments(final CommandContext context, final CommandAction action,
final Object[] args) throws ProcessingException {
         assert context != null;
+        assert action != null;
         assert args != null;
 
         //
@@ -170,6 +183,8 @@
 
         // Attach some help context
         CommandDocumenter documenter = getDocumenter();
+        assert documenter != null;
+
         HelpSupport help = new HelpSupport();
         clp.addBean(help);
         clp.addBean(documenter);



Mime
View raw message