geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r669861 - in /geronimo/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-plugin/src/main/java/org/apache/geronimo/gs...
Date Fri, 20 Jun 2008 11:31:33 GMT
Author: jdillon
Date: Fri Jun 20 04:31:33 2008
New Revision: 669861

URL: http://svn.apache.org/viewvc?rev=669861&view=rev
Log:
Replace CommandContainer with Command, replace CommandContainer.Locator with CommandFactory

Added:
    geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
  (contents, props changed)
      - copied, changed from r669852, geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandContainerDescriptor.java
    geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
  (contents, props changed)
      - copied, changed from r669849, 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/DefaultCommandFactory.java
  (contents, props changed)
      - copied, changed from r669849, geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java
Removed:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContainer.java
    geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandContainerDescriptor.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
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/CommandCompleter.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumenter.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.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/DefaultCommandLineExecutor.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=669861&r1=669860&r2=669861&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
Fri Jun 20 04:31:33 2008
@@ -33,4 +33,6 @@
     CommandDocumenter getDocumenter();
 
     CommandCompleter getCompleter();
+
+    Object execute(CommandContext context) throws Exception;
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompleter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompleter.java?rev=669861&r1=669860&r2=669861&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompleter.java
(original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandCompleter.java
Fri Jun 20 04:31:33 2008
@@ -24,7 +24,7 @@
  *
  * @version $Rev$ $Date$
  */
-public interface CommandCompleter // completer
+public interface CommandCompleter
 {
     // TODO:
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumenter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumenter.java?rev=669861&r1=669860&r2=669861&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumenter.java
(original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandDocumenter.java
Fri Jun 20 04:31:33 2008
@@ -24,7 +24,7 @@
  *
  * @version $Rev$ $Date$
  */
-public interface CommandDocumenter // documenter
+public interface CommandDocumenter
 {
     // TODO:
 }
\ No newline at end of file

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=669861&r1=669860&r2=669861&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 04:31:33 2008
@@ -24,8 +24,9 @@
 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.CommandContext;
+import org.apache.geronimo.gshell.command.CommandFactory;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.command.annotation.Requirement;
 import org.apache.geronimo.gshell.io.IO;
@@ -53,7 +54,7 @@
     private ApplicationManager applicationManager;
 
     @Requirement
-    private CommandContainer.Locator commandContainerLocator;
+    private CommandFactory commandFactory;
 
     @Requirement
     private LayoutManager layoutManager;
@@ -65,11 +66,11 @@
 
     public HelpCommand() {}
 
-    public HelpCommand(final CommandContainer.Locator commandContainerLocator, final LayoutManager
layoutManager) {
-        assert commandContainerLocator != null;
+    public HelpCommand(final CommandFactory commandFactory, final LayoutManager layoutManager)
{
+        assert commandFactory != null;
         assert layoutManager != null;
 
-        this.commandContainerLocator = commandContainerLocator;
+        this.commandFactory = commandFactory;
         this.layoutManager = layoutManager;
     }
 
@@ -119,10 +120,10 @@
                     CommandNode node = (CommandNode) child;
                     String name = StringUtils.rightPad(node.getName(), maxNameLen);
 
-                    CommandContainer container = commandContainerLocator.locate(node.getId());
+                    Command command = commandFactory.create(node.getId());
 
                     // FIXME:
-                    String desc = container.toString(); // command.getDescription();
+                    String desc = command.toString(); // command.getDescription();
 
                     io.out.print("  ");
                     io.out.print(renderer.render(Renderer.encode(name, Code.BOLD)));

Copied: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
(from r669852, geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandContainerDescriptor.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java?p2=geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java&p1=geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandContainerDescriptor.java&r1=669852&r2=669861&rev=669861&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandContainerDescriptor.java
(original)
+++ geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
Fri Jun 20 04:31:33 2008
@@ -19,10 +19,8 @@
 
 package org.apache.geronimo.gshell.plugin.descriptor;
 
-import org.apache.geronimo.gshell.command.CommandContainer;
-import org.apache.geronimo.gshell.yarn.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
 import org.apache.geronimo.gshell.model.command.CommandModel;
+import org.apache.geronimo.gshell.command.Command;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 
 /**
@@ -30,19 +28,19 @@
  *
  * @version $Rev$ $Date$
  */
-public class CommandContainerDescriptor
+public class CommandDescriptor
     extends ComponentDescriptorSupport
 {
     private final CommandModel model;
 
-    public CommandContainerDescriptor(final CommandModel model) {
+    public CommandDescriptor(final CommandModel model) {
         assert model != null;
 
         this.model = model;
 
-        setRole(CommandContainer.class);
+        setRole(Command.class);
         setRoleHint(model.getId());
-        setImplementation("org.apache.geronimo.gshell.rapture.DefaultCommandContainer");
+        setImplementation("org.apache.geronimo.gshell.rapture.DefaultCommand");
         setVersion(model.getVersion());
         setIsolatedRealm(false);
         setInstantiationStrategy("singleton");

Propchange: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/descriptor/CommandDescriptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=669861&r1=669860&r2=669861&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 04:31:33 2008
@@ -55,7 +55,7 @@
         addComponentDescriptor(new CommandActionDescriptor(model));
         addComponentDescriptor(new CommandDocumenterDescriptor(model));
         addComponentDescriptor(new CommandCompleterDescriptor(model));
-        addComponentDescriptor(new CommandContainerDescriptor(model));
+        addComponentDescriptor(new CommandDescriptor(model));
     }
 
     public void addComponentDescriptor(final ComponentDescriptor descriptor) {

Copied: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
(from r669849, 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/DefaultCommand.java?p2=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java&p1=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainer.java&r1=669849&r2=669861&rev=669861&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/DefaultCommand.java
Fri Jun 20 04:31:33 2008
@@ -24,9 +24,11 @@
 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.Command;
+import org.apache.geronimo.gshell.command.CommandDocumenter;
+import org.apache.geronimo.gshell.command.CommandCompleter;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
 import org.apache.geronimo.gshell.util.Arguments;
@@ -41,13 +43,13 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * The default {@link CommandContainer} component.
+ * The default {@link Command} component.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=CommandContainer.class)
-public class DefaultCommandContainer
-    implements CommandContainer, Contextualizable
+@Component(role=Command.class)
+public class DefaultCommand
+    implements Command, Contextualizable
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -67,7 +69,13 @@
         log.debug("Container: {}", container);
     }
 
-    private CommandAction getAction() {
+    // Command
+
+    public String getId() {
+        return commandId;
+    }
+
+    public CommandAction getAction() {
         assert container != null;
 
         try {
@@ -78,7 +86,27 @@
         }
     }
 
-    // CommandContainer
+    public CommandDocumenter getDocumenter() {
+        assert container != null;
+
+        try {
+            return container.lookupComponent(CommandDocumenter.class, commandId);
+        }
+        catch (ComponentLookupException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public CommandCompleter getCompleter() {
+        assert container != null;
+
+        try {
+            return container.lookupComponent(CommandCompleter.class, commandId);
+        }
+        catch (ComponentLookupException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;

Propchange: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandFactory.java
(from r669849, 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/DefaultCommandFactory.java?p2=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandFactory.java&p1=geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandContainerLocator.java&r1=669849&r2=669861&rev=669861&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/DefaultCommandFactory.java
Fri Jun 20 04:31:33 2008
@@ -19,8 +19,9 @@
 
 package org.apache.geronimo.gshell.rapture;
 
-import org.apache.geronimo.gshell.command.CommandContainer;
 import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
+import org.apache.geronimo.gshell.command.CommandFactory;
+import org.apache.geronimo.gshell.command.Command;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.repository.ComponentDescriptor;
@@ -32,13 +33,13 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * Default implementation of a {@link CommandContainer.Locator} component.
+ * Default implementation of a {@link CommandFactory} component.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=CommandContainer.Locator.class)
-public class DefaultCommandContainerLocator
-    implements CommandContainer.Locator, Contextualizable
+@Component(role= CommandFactory.class)
+public class DefaultCommandFactory
+    implements CommandFactory, Contextualizable
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -53,26 +54,26 @@
         log.debug("Container: {}", container);
     }
 
-    public CommandContainer locate(final String id) {
+    public Command create(final String id) throws Exception {
         assert id != null;
 
         log.debug("Locating container for ID: {}", id);
 
-        ComponentDescriptor descriptor = container.getComponentDescriptor(CommandContainer.class,
id);
+        ComponentDescriptor descriptor = container.getComponentDescriptor(Command.class,
id);
         if (descriptor == null) {
             // TODO: Throw typed exception
-            throw new RuntimeException("Command container not found for ID: " + id);
+            throw new Exception("Command container not found for ID: " + id);
         }
 
-        CommandContainer commandContainer;
+        Command command;
         try {
-            commandContainer = container.lookupComponent(CommandContainer.class, id);
+            command = container.lookupComponent(Command.class, id);
         }
         catch (ComponentLookupException e) {
             // TODO: Throw typed exception
-            throw new RuntimeException("Failed to access command container for ID: " + id,
e);
+            throw new Exception("Failed to access command container for ID: " + id, e);
         }
 
-        return commandContainer;
+        return command;
     }
 }
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommandFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=669861&r1=669860&r2=669861&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 04:31:33 2008
@@ -22,10 +22,11 @@
 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.command.CommandInfo;
 import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.CommandFactory;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.commandline.CommandExecutionFailied;
 import org.apache.geronimo.gshell.commandline.CommandLine;
 import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
@@ -76,7 +77,7 @@
     private LayoutManager layoutManager;
 
     @Requirement
-    private CommandContainer.Locator commandContainerLocator;
+    private CommandFactory commandFactory;
 
     @Requirement
     private CommandLineBuilder commandLineBuilder;
@@ -85,15 +86,15 @@
 
     public DefaultCommandLineExecutor() {}
     
-    public DefaultCommandLineExecutor(final ApplicationManager applicationManager, final
LayoutManager layoutManager, final CommandContainer.Locator commandContainerLocator, final
CommandLineBuilder commandLineBuilder) {
+    public DefaultCommandLineExecutor(final ApplicationManager applicationManager, final
LayoutManager layoutManager, final CommandFactory commandFactory, final CommandLineBuilder
commandLineBuilder) {
         assert applicationManager != null;
         assert layoutManager != null;
-        assert commandContainerLocator != null;
+        assert commandFactory != null;
         assert commandLineBuilder != null;
 
         this.applicationManager = applicationManager;
         this.layoutManager = layoutManager;
-        this.commandContainerLocator = commandContainerLocator;
+        this.commandFactory = commandFactory;
         this.commandLineBuilder = commandLineBuilder;
     }
 
@@ -237,9 +238,9 @@
         final String id = findCommandId(node);
         log.debug("Command ID: {}", id);
         
-        final CommandContainer container;
+        final Command command;
         try {
-            container = commandContainerLocator.locate(id);
+            command = commandFactory.create(id);
         }
         catch (Exception e) {
             throw new NotFoundException(e.getMessage());
@@ -310,7 +311,7 @@
 
         Object result;
         try {
-            result = container.execute(context);
+            result = command.execute(context);
 
             log.debug("Command completed with result: {}, after: {}", result, watch);
         }



Mime
View raw message