geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r699344 - in /geronimo/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/alias/ gshell-api/src/main/java/org/apache/geronimo/gshell/registry/ gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/...
Date Fri, 26 Sep 2008 14:44:57 GMT
Author: jdillon
Date: Fri Sep 26 07:44:56 2008
New Revision: 699344

URL: http://svn.apache.org/viewvc?rev=699344&view=rev
Log:
Re-implemented CommandRegistry bits
Added AliasRegistry
Added CommandResolverImpl which deals with finding command/alias in the path (currently all flat still)
Dropped the CommandManager and CommandRegistration muck

Added:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/AliasRegistry.java   (with props)
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/DuplicateCommandException.java   (with props)
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchAliasException.java   (with props)
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchCommandException.java   (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java   (contents, props changed)
      - copied, changed from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.java   (contents, props changed)
      - copied, changed from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasDefinedEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java   (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.java   (contents, props changed)
      - copied, changed from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasUndefinedEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java   (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.java   (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java   (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/registry/
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.properties   (props changed)
      - copied unchanged from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.properties
Removed:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/alias/
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandNotFoundException.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistration.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandManager.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/alias/
Modified:
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistry.java
    geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandResolver.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnaliasAction.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegisteredEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupCommand.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/PluginParserTest.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml

Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/AliasRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/AliasRegistry.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/AliasRegistry.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/AliasRegistry.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.registry;
+
+import java.util.Collection;
+
+/**
+ * Registry for command aliases.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AliasRegistry
+{
+    void registerAlias(String name, String alias);
+
+    void removeAlias(String name) throws NoSuchAliasException;
+
+    String getAlias(String name) throws NoSuchAliasException;
+    
+    boolean containsAlias(String name);
+
+    Collection<String> getAliasNames();
+}
\ No newline at end of file

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

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

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

Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistry.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/CommandRegistry.java Fri Sep 26 07:44:56 2008
@@ -24,17 +24,19 @@
 import java.util.Collection;
 
 /**
- * Provides registration facilities for {@link org.apache.geronimo.gshell.command.Command} instances.
+ * Registry for commands.
  *
  * @version $Rev$ $Date$
  */
 public interface CommandRegistry
 {
-    CommandRegistration register(Command command);
+    void registerCommand(String name, Command command) throws DuplicateCommandException;
 
-    // boolean isRegistered(String name);
+    void removeCommand(String name) throws NoSuchCommandException;
 
-    // void unregister(String name);
+    Command getCommand(String name) throws NoSuchCommandException;
 
-    Collection<CommandRegistration> getRegistrations();
+    boolean containsCommand(String name);
+
+    Collection<String> getCommandNames();
 }
\ 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=699344&r1=699343&r2=699344&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 Fri Sep 26 07:44:56 2008
@@ -24,7 +24,7 @@
 import org.apache.geronimo.gshell.command.CommandException;
 
 /**
- * Resolves {@link org.apache.geronimo.gshell.command.Command} instances for a given path.
+ * Resolves {@link Command} instances for a given path.
  *
  * @version $Rev$ $Date$
  */
@@ -37,7 +37,7 @@
      * @param path          The path of the command to resolve.
      * @return              The resolved command instance; never null.
      *
-     * @throws org.apache.geronimo.gshell.command.CommandException     Failed to resolve command.
+     * @throws CommandException     Failed to resolve command.
      */
     Command resolve(Variables variables, String path) throws CommandException;
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/DuplicateCommandException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/DuplicateCommandException.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/DuplicateCommandException.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/DuplicateCommandException.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.registry;
+
+import org.apache.geronimo.gshell.command.CommandException;
+
+/**
+ * Thrown to indicate a duplicate command registration attempt has failed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateCommandException
+    extends CommandException
+{
+    public DuplicateCommandException(final String msg) {
+        super(msg);
+    }
+
+    public DuplicateCommandException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public DuplicateCommandException(final Throwable cause) {
+        super(cause);
+    }
+
+    public DuplicateCommandException() {
+        super();
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchAliasException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchAliasException.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchAliasException.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchAliasException.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.registry;
+
+import org.apache.geronimo.gshell.command.CommandException;
+
+/**
+ * Thrown to indicate that a requested named-alias was not found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoSuchAliasException
+    extends CommandException
+{
+    public NoSuchAliasException(final String msg) {
+        super(msg);
+    }
+
+    public NoSuchAliasException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public NoSuchAliasException(final Throwable cause) {
+        super(cause);
+    }
+
+    public NoSuchAliasException() {
+        super();
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchCommandException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchCommandException.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchCommandException.java (added)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/registry/NoSuchCommandException.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.registry;
+
+import org.apache.geronimo.gshell.command.CommandException;
+
+/**
+ * Thrown to indicate that a requested named-command was not found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoSuchCommandException
+    extends CommandException
+{
+    public NoSuchCommandException(final String msg) {
+        super(msg);
+    }
+
+    public NoSuchCommandException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public NoSuchCommandException(final Throwable cause) {
+        super(cause);
+    }
+
+    public NoSuchCommandException() {
+        super();
+    }
+}
\ No newline at end of file

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

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

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

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java Fri Sep 26 07:44:56 2008
@@ -19,13 +19,15 @@
 
 package org.apache.geronimo.gshell.commands.builtins;
 
-import org.apache.geronimo.gshell.alias.Alias;
-import org.apache.geronimo.gshell.alias.AliasManager;
+import org.apache.geronimo.gshell.ansi.Code;
+import org.apache.geronimo.gshell.ansi.Renderer;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.i18n.MessageSource;
 import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +45,7 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
-    private AliasManager aliasManager;
+    private AliasRegistry aliasRegistry;
 
     @Argument(index=0)
     private String name;
@@ -53,36 +55,68 @@
 
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;
-        IO io = context.getIo();
-        MessageSource messages = context.getCommand().getMessages();
 
         if (name == null) {
-            log.debug("Listing defined aliases");
+            return listAliases(context);
+        }
+        else {
+            return defineAlias(context);
+        }
+    }
 
-            Collection<Alias> aliases = aliasManager.getAliases();
-            
-            if (aliases.isEmpty()) {
-                io.info("No aliases have been defined");
-            }
-            else {
-                io.info("Defined aliases:");
+    private Object listAliases(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        log.debug("Listing defined aliases");
+
+        Collection<String> names = aliasRegistry.getAliasNames();
 
-                for (Alias alias : aliases) {
-                    io.info("  {}='{}'", alias.getName(), alias.getTarget());
+        if (names.isEmpty()) {
+            io.info("No aliases have been defined");
+        }
+        else {
+            // Determine the maximun name length
+            int maxNameLen = 0;
+            for (String name : names) {
+                if (name.length() > maxNameLen) {
+                    maxNameLen = name.length();
                 }
             }
+
+            io.out.println("Defined aliases:");
+            for (String name : names) {
+                String alias = aliasRegistry.getAlias(name);
+                String formattedName = StringUtils.rightPad(name, maxNameLen);
+
+                io.out.print("  ");
+                io.out.print(Renderer.encode(formattedName, Code.BOLD));
+
+                io.out.print("  ");
+                io.out.print("Alias to: ");
+                io.out.println(alias);
+            }
+
+            io.out.println();
         }
-        else if (target == null) {
+
+        return Result.SUCCESS;
+    }
+
+    private Object defineAlias(final CommandContext context) throws Exception {
+        assert context != null;
+        IO io = context.getIo();
+
+        if (target == null) {
+            MessageSource messages = context.getCommand().getMessages();
             io.error("Missing argument: {}", messages.getMessage("command.argument.target.token"));
+
             return Result.FAILURE;
         }
-        else {
-            log.debug("Defining alias: {} -> {}", name, target);
 
-            Alias alias = aliasManager.defineAlias(name, target);
+        log.debug("Defining alias: {} -> {}", name, target);
 
-            log.debug("Alias: {}", alias);
-        }
+        aliasRegistry.registerAlias(name, target);
 
         return Result.SUCCESS;
     }

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java Fri Sep 26 07:44:56 2008
@@ -26,9 +26,10 @@
 import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.command.CommandDocumenter;
-import org.apache.geronimo.gshell.registry.CommandRegistration;
-import org.apache.geronimo.gshell.registry.CommandRegistry;
 import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.NoSuchCommandException;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,58 +69,61 @@
 
         log.debug("Displaying help manual for command: {}", commandName);
 
-        // FIXME: Should resolve the commandName/commandPath
-
-        assert commandRegistry != null;
-        Collection<CommandRegistration> registrations = commandRegistry.getRegistrations();
+        try {
+            assert commandRegistry != null;
+            Command command = commandRegistry.getCommand(commandName);
 
-        for (CommandRegistration registration : registrations) {
-            Command command = registration.getCommand();
-            CommandDocumenter doc = command.getDocumenter();
+            assert command != null;
+            command.getDocumenter().renderManual(io.out);
 
-            if (doc.getName().equals(commandName)) {
-                doc.renderManual(io.out);
-
-                return Result.SUCCESS;
-            }
+            return Result.SUCCESS;
         }
+        catch (NoSuchCommandException e) {
+            //
+            // FIXME: When the commandName is really an alias, show the alias details here instead of complaining
+            //
+            
+            io.out.print("Command ");
+            io.out.print(Renderer.encode(commandName, Code.BOLD));
+            io.out.println(" not found.");
+
+            io.out.print("Try ");
+            io.out.print(Renderer.encode("help", Code.BOLD));
+            io.out.println(" for a list of available commands.");
 
-        io.out.print("Command ");
-        io.out.print(Renderer.encode(commandName, Code.BOLD));
-        io.out.println(" not found.");
-
-        io.out.print("Try ");
-        io.out.print(Renderer.encode("help", Code.BOLD));
-        io.out.println(" for a list of available commands.");
-
-        io.out.println();
+            io.out.println();
 
-        return Result.FAILURE;
+            return Result.FAILURE;
+        }
     }
 
-    private Object displayAvailableCommands(final CommandContext context) {
+    private Object displayAvailableCommands(final CommandContext context) throws Exception {
         assert context != null;
         IO io = context.getIo();
 
         log.debug("Listing brief help for commands");
 
-        // FIXME: Figure this out dynamically
-        int maxNameLen = 20;
-
         assert commandRegistry != null;
-        Collection<CommandRegistration> registrations = commandRegistry.getRegistrations();
+        Collection<String> names = commandRegistry.getCommandNames();
 
-        io.out.println("Available commands:");
+        // Determine the maximun name length
+        int maxNameLen = 0;
+        for (String name : names) {
+            if (name.length() > maxNameLen) {
+                maxNameLen = name.length();
+            }
+        }
 
-        for (CommandRegistration registration : registrations) {
-            Command command = registration.getCommand();
-            CommandDocumenter doc = command.getDocumenter();
+        io.out.println("Available commands:");
+        for (String name : names) {
+            Command command = commandRegistry.getCommand(name);
+            CommandDocumenter documenter = command.getDocumenter();
 
-            String name = StringUtils.rightPad(doc.getName(), maxNameLen);
-            String desc = doc.getDescription();
+            String formattedName = StringUtils.rightPad(name, maxNameLen);
+            String desc = documenter.getDescription();
 
             io.out.print("  ");
-            io.out.print(Renderer.encode(name, Code.BOLD));
+            io.out.print(Renderer.encode(formattedName, Code.BOLD));
 
             if (desc != null) {
                 io.out.print("  ");

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnaliasAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnaliasAction.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnaliasAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnaliasAction.java Fri Sep 26 07:44:56 2008
@@ -22,8 +22,9 @@
 import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.alias.AliasManager;
 import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.apache.geronimo.gshell.registry.NoSuchAliasException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,24 +40,26 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
-    private AliasManager aliasManager;
+    private AliasRegistry aliasRegistry;
     
     @Argument(index=0, required=true)
     private String name;
 
-    public Object execute(final CommandContext context) throws Exception {
+    public Object execute(final CommandContext context) {
         assert context != null;
         IO io = context.getIo();
 
         log.debug("Undefining alias: {}", name);
 
-        if (!aliasManager.isAliasDefined(name)) {
-            io.error("No alias defined with name: {}", name);
-            return Result.FAILURE;
-        }
+        try {
+            aliasRegistry.removeAlias(name);
 
-        aliasManager.undefineAlias(name);
+            return Result.SUCCESS;
+        }
+        catch (NoSuchAliasException e) {
+            io.error("No alias defined: {}", name);
 
-        return Result.SUCCESS;
+            return Result.FAILURE;
+        }
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java Fri Sep 26 07:44:56 2008
@@ -19,9 +19,6 @@
 
 package org.apache.geronimo.gshell.wisdom.config;
 
-import org.apache.geronimo.gshell.wisdom.alias.AliasCommand;
-import org.apache.geronimo.gshell.wisdom.plugin.PluginImpl;
-import org.apache.geronimo.gshell.wisdom.plugin.activation.DefaultCommandBundleActivationRule;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,7 +27,7 @@
 import org.springframework.beans.factory.config.BeanDefinitionHolder;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
 import org.springframework.beans.factory.xml.ParserContext;
@@ -39,7 +36,9 @@
 import org.w3c.dom.Element;
 
 import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Parser for the &lt;gshell:plugin/&gt; element.
@@ -52,7 +51,9 @@
     private static final String ID = "id";
 
     private static final String DESCRIPTION = "description";
-    
+
+    private static final String PLUGIN_TEMPLATE = "pluginTemplate";
+
     private static final String ACTION = "action";
 
     private static final String ACTION_ID = "actionId";
@@ -80,8 +81,8 @@
     private static final String PROTOTYPE = "prototype";
 
     private static final String ALIAS = "alias";
-
-    private static final String TARGET = "target";
+    
+    private static final String ALIASES = "aliases";
 
     @Override
     protected boolean shouldGenerateId() {
@@ -239,22 +240,13 @@
 
             BeanDefinitionBuilder plugin = parsePlugin(element);
 
-            List<BeanDefinitionHolder> bundles = parseCommandBundles(element);
+            /*List<BeanDefinitionHolder> bundles =*/ parseCommandBundles(element);
 
+            /*
             for (BeanDefinitionHolder holder : bundles) {
                 // TODO: Handle registration of the bundles?
             }
-
-            //
-            // HACK: For now hard-code a single activation rule
-            //
-
-            BeanDefinitionBuilder rule = BeanDefinitionBuilder.rootBeanDefinition(DefaultCommandBundleActivationRule.class);
-            rule.addPropertyValue("bundleId", "default");
-            ManagedList rules = new ManagedList();
-            // noinspection unchecked
-            rules.add(rule.getBeanDefinition());
-            plugin.addPropertyValue("activationRules", rules);
+            */
 
             return plugin;
         }
@@ -264,7 +256,7 @@
 
             log.trace("Parse plugin; element: {}", element);
 
-            BeanDefinitionBuilder plugin = BeanDefinitionBuilder.rootBeanDefinition(PluginImpl.class);
+            BeanDefinitionBuilder plugin = BeanDefinitionBuilder.childBeanDefinition(PLUGIN_TEMPLATE);
             plugin.addPropertyValue(ID, element.getAttribute(NAME));
 
             parseAndApplyDescription(element, plugin);
@@ -291,8 +283,6 @@
                 BeanDefinition def = bundle.getBeanDefinition();
                 String id = resolveId(child, def);
                 BeanDefinitionHolder holder = register(def, id);
-
-                // noinspection unchecked
                 holders.add(holder);
             }
 
@@ -305,18 +295,25 @@
             log.trace("Parse command bundle; element; {}", element);
 
             BeanDefinitionBuilder bundle = BeanDefinitionBuilder.rootBeanDefinition(CommandBundle.class);
-            bundle.addPropertyValue(ID, element.getAttribute(NAME));
+            bundle.addConstructorArgValue(element.getAttribute(NAME));
             bundle.setLazyInit(true);
             parseAndApplyDescription(element, bundle);
 
-            List commands = parseCommands(element);
-            List aliases = parseAliases(element);
+            //
+            // NOTE: Seems we have to use ManagedMap to inject things properly.
+            //       But they are not generic, so so limit their usage here.
+            //
 
+            ManagedMap commands = new ManagedMap();
             // noinspection unchecked
-            commands.addAll(aliases);
-
+            commands.putAll(parseCommands(element));
             bundle.addPropertyValue(COMMANDS, commands);
 
+            ManagedMap aliases = new ManagedMap();
+            // noinspection unchecked
+            aliases.putAll(parseAliases(element));
+            bundle.addPropertyValue(ALIASES, aliases);
+
             return bundle;
         }
 
@@ -324,22 +321,22 @@
         // <gshell:command>
         //
 
-        private List parseCommands(final Element element) {
+        private Map<String,BeanDefinition> parseCommands(final Element element) {
             assert element != null;
 
             log.trace("Parse commands; element; {}", element);
 
+            Map<String,BeanDefinition> commands = new LinkedHashMap<String,BeanDefinition>();
+
             List<Element> children = getChildElements(element, COMMAND);
-            ManagedList defs = new ManagedList();
 
             for (Element child : children) {
+                String name = child.getAttribute(NAME);
                 BeanDefinitionBuilder command = parseCommand(child);
-
-                // noinspection unchecked
-                defs.add(command.getBeanDefinition());
+                commands.put(name, command.getBeanDefinition());
             }
 
-            return defs;
+            return commands;
         }
 
         private BeanDefinitionBuilder parseCommand(final Element element) {
@@ -351,9 +348,6 @@
             BeanDefinitionBuilder command = BeanDefinitionBuilder.childBeanDefinition(type.getTemplateName());
             parseAndApplyDescription(element, command);
 
-            // TODO: Currently name is pulled from the documentor, need to change that
-            // command.addPropertyValue("name", element.getAttribute("name"));
-
             Element child;
 
             // Required children elements
@@ -409,37 +403,23 @@
         // <gshell:alias>
         //
 
-        private List parseAliases(final Element element) {
+        private Map<String,String> parseAliases(final Element element) {
             assert element != null;
 
             log.trace("Parse aliases; element; {}", element);
 
+            Map<String,String> aliases = new LinkedHashMap<String,String>();
+
             List<Element> children = getChildElements(element, ALIAS);
-            ManagedList defs = new ManagedList();
 
             for (Element child : children) {
-                BeanDefinitionBuilder command = parseAlias(child);
+                String name = child.getAttribute(NAME);
+                String alias = child.getAttribute(ALIAS);
 
-                // noinspection unchecked
-                defs.add(command.getBeanDefinition());
+                aliases.put(name, alias);
             }
 
-            return defs;
-        }
-
-        private BeanDefinitionBuilder parseAlias(final Element element) {
-            assert element != null;
-
-            log.trace("Parse alias; element; {}", element);
-
-            BeanDefinitionBuilder alias = BeanDefinitionBuilder.rootBeanDefinition(AliasCommand.class);
-            alias.addConstructorArgValue(element.getAttribute(NAME));
-            alias.addConstructorArgValue(element.getAttribute(TARGET));
-
-            parseAndApplyDescription(element, alias);
-
-            return alias;
+            return aliases;
         }
-
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java Fri Sep 26 07:44:56 2008
@@ -21,6 +21,7 @@
 
 import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
@@ -43,9 +44,22 @@
     @Autowired
     private CommandRegistry commandRegistry;
 
+    @Autowired
+    private AliasRegistry aliasRegistry;
+
     private BeanContainer container;
 
-    private String bundleId;
+    private String bundleName;
+
+    public String getBundleName() {
+        return bundleName;
+    }
+
+    public void setBundleName(final String bundleName) {
+        assert bundleName != null;
+        
+        this.bundleName = bundleName;
+    }
 
     public void setBeanContainer(final BeanContainer container) {
         assert container != null;
@@ -53,12 +67,24 @@
         this.container = container;
     }
 
-    public String getBundleId() {
-        return bundleId;
-    }
+    private CommandBundle getBundle() {
+        assert container != null;
+        Map<String, CommandBundle> bundles = container.getBeans(CommandBundle.class);
+
+        assert bundleName != null;
+        CommandBundle bundle = null;
+        for (CommandBundle b : bundles.values()) {
+            if (b.getName().equals(bundleName)) {
+                bundle = b;
+                break;
+            }
+        }
 
-    public void setBundleId(final String bundleId) {
-        this.bundleId = bundleId;
+        if (bundle == null) {
+            throw new RuntimeException("No bundle found with name: " + bundleName);
+        }
+
+        return bundle;
     }
 
     public void evaluate(final ActivationContext context) throws Exception {
@@ -67,30 +93,20 @@
         if (context.getTasks().isEmpty()) {
             ActivationTask task = new ActivationTask() {
                 public void execute() throws Exception {
-                    assert container != null;
-                    Map<String, CommandBundle> bundles = container.getBeans(CommandBundle.class);
+                    CommandBundle bundle = getBundle();
+                    
+                    log.debug("Processing command bundle: {}", bundle);
 
-                    assert bundleId != null;
-                    CommandBundle bundle = null;
-                    for (CommandBundle b : bundles.values()) {
-                        if (b.getId().equals(bundleId)) {
-                            bundle = b;
-                            break;
-                        }
-                    }
+                    Map<String,Command> commands = bundle.getCommands();
 
-                    if (bundle == null) {
-                        throw new Exception("No bundle found with id: " + bundleId);
+                    for (String name : commands.keySet()) {
+                        commandRegistry.registerCommand(name, commands.get(name));
                     }
 
-                    log.debug("Processing command bundle: {}", bundle.getId());
-
-                    if (!bundle.isEmpty()) {
-                        log.debug("Discovered {} commands in bundle {}", bundle.size(), bundle.getId());
+                    Map<String,String> aliases = bundle.getAliases();
 
-                        for (Command command : bundle.getCommands()) {
-                            commandRegistry.register(command);
-                        }
+                    for (String name : aliases.keySet()) {
+                        aliasRegistry.registerAlias(name, aliases.get(name));
                     }
                 }
             };

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java Fri Sep 26 07:44:56 2008
@@ -26,7 +26,7 @@
  */
 public interface Bundle
 {
-    String getId();
+    String getName();
 
     // TODO: start/stop enable/disable close/destroy
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java Fri Sep 26 07:44:56 2008
@@ -21,7 +21,7 @@
 
 import org.apache.geronimo.gshell.command.Command;
 
-import java.util.List;
+import java.util.Map;
 
 /**
  * A bundle of {@link Command} instances.
@@ -31,35 +31,39 @@
 public class CommandBundle
     implements Bundle
 {
-    private String id;
+    private String name;
 
-    private List<Command> commands;
+    private Map<String,Command> commands;
 
-    public String getId() {
-        return id;
+    private Map<String,String> aliases;
+
+    public CommandBundle(final String name) {
+        assert name != null;
+
+        this.name = name;
     }
 
-    public void setId(final String id) {
-        assert id != null;
-        
-        this.id = id;
+    public String getName() {
+        return name;
     }
 
-    public List<Command> getCommands() {
+    public Map<String, Command> getCommands() {
         return commands;
     }
 
-    public void setCommands(final List<Command> commands) {
+    public void setCommands(final Map<String, Command> commands) {
         assert commands != null;
-
+        
         this.commands = commands;
     }
 
-    public int size() {
-        return commands != null ? commands.size() : 0;
+    public Map<String, String> getAliases() {
+        return aliases;
     }
-    
-    public boolean isEmpty() {
-        return size() == 0;
+
+    public void setAliases(final Map<String, String> aliases) {
+        assert aliases != null;
+
+        this.aliases = aliases;
     }
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java (from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java&r1=699243&r2=699344&rev=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java Fri Sep 26 07:44:56 2008
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.wisdom.alias;
+package org.apache.geronimo.gshell.wisdom.registry;
 
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandAction;
@@ -50,14 +50,14 @@
 
     private String name;
 
-    private String target;
+    private String alias;
 
-    public AliasCommand(final String name, final String target) {
+    public AliasCommand(final String name, final String alias) {
         assert name != null;
-        assert target != null;
+        assert alias != null;
 
         this.name = name;
-        this.target = target;
+        this.alias = alias;
 
         setAction(new AliasCommandAction());
         setDocumenter(new AliasCommandDocumenter());
@@ -65,8 +65,8 @@
         setMessages(new AliasCommandMessageSource());
     }
 
-    public AliasCommand(final String name, final String target, final CommandLineExecutor executor) {
-        this(name, target);
+    public AliasCommand(final String name, final String alias, final CommandLineExecutor executor) {
+        this(name, alias);
 
         assert executor != null;
 
@@ -103,16 +103,19 @@
             };
 
             StringBuilder buff = new StringBuilder();
-            buff.append(target);
+            buff.append(alias);
 
             // If we have args to append, then do it
             if (appendArgs != null && !appendArgs.isEmpty()) {
                 buff.append(" ");
-                
+
+                // Append args quoted as they have already been processed by the parser
                 Iterator iter = appendArgs.iterator();
                 while (iter.hasNext()) {
-                    // Append args quoted as they have already been processed by the parser
+                    //
                     // HACK: Using double quote instead of single quote for now as the parser's handling of single quote is broken
+                    //
+
                     buff.append('"').append(iter.next()).append('"');
                     if (iter.hasNext()) {
                         buff.append(" ");
@@ -120,7 +123,7 @@
                 }
             }
 
-            log.debug("Executing alias target: {}", buff);
+            log.debug("Executing alias: {}", buff);
 
             Object result = executor.execute(shellContext, buff.toString());
 
@@ -141,7 +144,7 @@
         }
 
         public String getDescription() {
-            return getMessages().format(COMMAND_DESCRIPTION, target);
+            return getMessages().format(COMMAND_DESCRIPTION, alias);
         }
     }
 

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.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/registry/AliasCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.java (from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasDefinedEvent.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasDefinedEvent.java&r1=699243&r2=699344&rev=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasDefinedEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.java Fri Sep 26 07:44:56 2008
@@ -17,28 +17,35 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.wisdom.alias;
+package org.apache.geronimo.gshell.wisdom.registry;
 
-import org.apache.geronimo.gshell.alias.Alias;
 import org.apache.geronimo.gshell.event.Event;
 
 /**
- * Event fired once an alias has been defined.
+ * Event fired once an alias has been registered.
  *
  * @version $Rev$ $Date$
  */
-public class AliasDefinedEvent
+public class AliasRegisteredEvent
     implements Event
 {
-    private final Alias alias;
+    private final String name;
 
-    public AliasDefinedEvent(final Alias alias) {
+    private final String alias;
+
+    public AliasRegisteredEvent(final String name, final String alias) {
+        assert name != null;
         assert alias != null;
 
+        this.name = name;
         this.alias = alias;
     }
 
-    public Alias getAlias() {
+    public String getName() {
+        return name;
+    }
+
+    public String getAlias() {
         return alias;
     }
 }
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegisteredEvent.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/registry/AliasRegisteredEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.registry;
+
+import org.apache.geronimo.gshell.event.EventPublisher;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.apache.geronimo.gshell.registry.NoSuchAliasException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * {@link AliasRegistry} component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AliasRegistryImpl
+    implements AliasRegistry
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private EventPublisher eventPublisher;
+
+    private final Map<String,String> aliases = new LinkedHashMap<String,String>();
+
+    public void registerAlias(final String name, final String alias) {
+        assert name != null;
+        assert alias != null;
+
+        log.debug("Registering alias: {} -> {}", name, alias);
+
+        if (containsAlias(name)) {
+            log.debug("Replacing alias: {}", name);
+        }
+
+        aliases.put(name, alias);
+
+        eventPublisher.publish(new AliasRegisteredEvent(name, alias));
+    }
+
+    public void removeAlias(final String name) throws NoSuchAliasException {
+        assert name != null;
+
+        log.debug("Removing alias: {}", name);
+        
+        if (!containsAlias(name)) {
+            throw new NoSuchAliasException(name);
+        }
+
+        aliases.remove(name);
+
+        eventPublisher.publish(new AliasRemovedEvent(name));
+    }
+
+    public String getAlias(final String name) throws NoSuchAliasException {
+        assert name != null;
+
+        if (!containsAlias(name)) {
+            throw new NoSuchAliasException(name);
+        }
+
+        return aliases.get(name);
+    }
+
+    public boolean containsAlias(final String name) {
+        assert name != null;
+
+        return aliases.containsKey(name);
+    }
+
+    public Collection<String> getAliasNames() {
+        return Collections.unmodifiableSet(aliases.keySet());
+    }
+}
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRegistryImpl.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/registry/AliasRegistryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.java (from r699243, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasUndefinedEvent.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasUndefinedEvent.java&r1=699243&r2=699344&rev=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasUndefinedEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.java Fri Sep 26 07:44:56 2008
@@ -17,28 +17,27 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.wisdom.alias;
+package org.apache.geronimo.gshell.wisdom.registry;
 
-import org.apache.geronimo.gshell.alias.Alias;
 import org.apache.geronimo.gshell.event.Event;
 
 /**
- * Event fired once an alias has been undefined.
+ * Event fired once an alias has been removed.
  *
  * @version $Rev$ $Date$
  */
-public class AliasUndefinedEvent
+public class AliasRemovedEvent
     implements Event
 {
-    private final Alias alias;
+    private final String name;
 
-    public AliasUndefinedEvent(final Alias alias) {
-        assert alias != null;
+    public AliasRemovedEvent(final String name) {
+        assert name != null;
 
-        this.alias = alias;
+        this.name = name;
     }
 
-    public Alias getAlias() {
-        return alias;
+    public String getName() {
+        return name;
     }
 }
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasRemovedEvent.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/registry/AliasRemovedEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegisteredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegisteredEvent.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegisteredEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegisteredEvent.java Fri Sep 26 07:44:56 2008
@@ -19,7 +19,7 @@
 
 package org.apache.geronimo.gshell.wisdom.registry;
 
-import org.apache.geronimo.gshell.registry.CommandRegistration;
+import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.event.Event;
 
 /**
@@ -30,15 +30,23 @@
 public class CommandRegisteredEvent
     implements Event
 {
-    private final CommandRegistration registration;
+    private final String name;
 
-    public CommandRegisteredEvent(final CommandRegistration registration) {
-        assert registration != null;
+    private final Command command;
 
-        this.registration = registration;
+    public CommandRegisteredEvent(final String name, final Command command) {
+        assert name != null;
+        assert command != null;
+
+        this.name = name;
+        this.command =  command;
+    }
+
+    public String getName() {
+        return name;
     }
 
-    public CommandRegistration getRegistration() {
-        return registration;
+    public Command getCommand() {
+        return command;
     }
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.registry;
+
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.event.EventPublisher;
+import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.NoSuchCommandException;
+import org.apache.geronimo.gshell.registry.DuplicateCommandException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * {@link CommandRegistry} component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CommandRegistryImpl
+    implements CommandRegistry
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private EventPublisher eventPublisher;
+
+    private final Map<String,Command> commands = new LinkedHashMap<String,Command>();
+
+    public void registerCommand(final String name, final Command command) throws DuplicateCommandException {
+        assert name != null;
+        assert command != null;
+
+        log.debug("Registering command: {} -> {}", name, command);
+
+        if (containsCommand(name)) {
+            throw new DuplicateCommandException(name);
+        }
+
+        commands.put(name, command);
+
+        eventPublisher.publish(new CommandRegisteredEvent(name, command));
+    }
+
+    public void removeCommand(final String name) throws NoSuchCommandException {
+        assert name != null;
+
+        log.debug("Removing command: {}", name);
+
+        if (!containsCommand(name)) {
+            throw new NoSuchCommandException(name);
+        }
+
+        commands.remove(name);
+
+        eventPublisher.publish(new CommandRemovedEvent(name));
+    }
+
+    public Command getCommand(final String name) throws NoSuchCommandException {
+        assert name != null;
+
+        if (!containsCommand(name)) {
+            throw new NoSuchCommandException(name);
+        }
+
+        return commands.get(name);
+    }
+
+    public boolean containsCommand(final String name) {
+        assert name != null;
+
+        return commands.containsKey(name);
+    }
+
+    public Collection<String> getCommandNames() {
+        return Collections.unmodifiableSet(commands.keySet());
+    }
+}
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRegistryImpl.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/registry/CommandRegistryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.registry;
+
+import org.apache.geronimo.gshell.event.Event;
+
+/**
+ * Event fired once a command has been removed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CommandRemovedEvent
+    implements Event
+{
+    private final String name;
+
+    public CommandRemovedEvent(final String name) {
+        assert name != null;
+
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandRemovedEvent.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/registry/CommandRemovedEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java?rev=699344&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java (added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java Fri Sep 26 07:44:56 2008
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.registry;
+
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.command.CommandException;
+import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.CommandResolver;
+import org.apache.geronimo.gshell.registry.NoSuchAliasException;
+import org.apache.geronimo.gshell.spring.BeanContainer;
+import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.geronimo.gshell.wisdom.registry.AliasCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * {@link CommandResolver} component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CommandResolverImpl
+    implements CommandResolver, BeanContainerAware
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CommandRegistry commandRegistry;
+
+    @Autowired
+    private AliasRegistry aliasRegistry;
+
+    @Autowired
+    private CommandLineExecutor executor;
+
+    private BeanContainer container;
+
+    public void setBeanContainer(final BeanContainer container) {
+        assert container != null;
+
+        this.container = container;
+    }
+
+    public Command resolve(final Variables variables, final String path) throws CommandException {
+        assert variables != null;
+        assert path != null;
+
+        log.debug("Resolving command for path: {}", path);
+
+        //
+        // FIXME: For now just ask for the named stuff, eventually need a better path parser and lookup thingy
+        //
+
+        Command command;
+
+        assert aliasRegistry != null;
+        if (aliasRegistry.containsAlias(path)) {
+            command = createAliasCommand(path);
+        }
+        else {
+            assert commandRegistry != null;
+            command = commandRegistry.getCommand(path);
+        }
+
+        log.debug("Resolved command: {} -> {}", path, command);
+        
+        return command;
+    }
+
+    private Command createAliasCommand(final String name) throws NoSuchAliasException {
+        assert name != null;
+
+        log.debug("Creating command for alias: {}", name);
+
+        assert aliasRegistry != null;
+        String alias = aliasRegistry.getAlias(name);
+        AliasCommand command = new AliasCommand(name, alias, executor);
+
+        //
+        // FIXME: Have to inject the container because we are not wiring ^^^, and because its support muck needs some crap
+        //        probably need to use a prototype here
+        //
+
+        assert container != null;
+        command.setBeanContainer(container);
+
+        return command;
+    }
+}

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.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/registry/CommandResolverImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupCommand.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupCommand.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/GroupCommand.java Fri Sep 26 07:44:56 2008
@@ -22,8 +22,6 @@
 import org.apache.geronimo.gshell.command.CommandResult;
 import org.apache.geronimo.gshell.shell.ShellContext;
 import org.apache.geronimo.gshell.wisdom.command.CommandSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Group {@link org.apache.geronimo.gshell.command.Command} component.

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=699344&r1=699343&r2=699344&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 Fri Sep 26 07:44:56 2008
@@ -26,9 +26,13 @@
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <bean id="pluginManager" class="org.apache.geronimo.gshell.wisdom.plugin.PluginManagerImpl"/>
-    
-    <bean id="commandManager" class="org.apache.geronimo.gshell.wisdom.registry.CommandManager"/>
 
+    <bean id="aliasRegistry" class="org.apache.geronimo.gshell.wisdom.registry.AliasRegistryImpl"/>
+
+    <bean id="commandRegistry" class="org.apache.geronimo.gshell.wisdom.registry.CommandRegistryImpl"/>
+
+    <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.registry.CommandResolverImpl"/>
+    
     <bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl"/>
 
     <bean id="commandLineExecutor" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineExecutorImpl"/>
@@ -39,7 +43,15 @@
 
     <bean id="shell" class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl"/>
 
-    <bean id="aliasManager" class="org.apache.geronimo.gshell.wisdom.alias.AliasManagerImpl"/>
+    <bean id="pluginTemplate" class="org.apache.geronimo.gshell.wisdom.plugin.PluginImpl" abstract="true">
+        <property name="activationRules">
+            <list>
+                <bean class="org.apache.geronimo.gshell.wisdom.plugin.activation.DefaultCommandBundleActivationRule">
+                    <property name="bundleName" value="default"/>
+                </bean>
+            </list>
+        </property>
+    </bean>
 
     <bean id="statelessCommandTemplate" class="org.apache.geronimo.gshell.wisdom.command.StatelessCommand" abstract="true">
         <property name="documenter">

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd Fri Sep 26 07:44:56 2008
@@ -210,14 +210,14 @@
         <xsd:complexType>
             <xsd:annotation>
                 <xsd:documentation>
-                    Defines an alias.
+                    Defines a command alias.
                 </xsd:documentation>
             </xsd:annotation>
             <xsd:sequence>
                 <xsd:element ref="beans:description" minOccurs="0" maxOccurs="1"/>
             </xsd:sequence>
             <xsd:attribute name="name" type="xsd:string" use="required"/>
-            <xsd:attribute name="target" type="xsd:string" use="required"/>
+            <xsd:attribute name="alias" type="xsd:string" use="required"/>
         </xsd:complexType>
     </xsd:element>
 

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/registry/AliasCommand.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/PluginParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/PluginParserTest.java?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/PluginParserTest.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/PluginParserTest.java Fri Sep 26 07:44:56 2008
@@ -30,6 +30,15 @@
 public class PluginParserTest
     extends SpringTestSupport
 {
+    /*
+    protected String[] getConfigLocations() {
+        return new String[] {
+            "classpath:META-INF/spring/components.xml",
+            "classpath:" + getClass().getName().replace('.', '/') + "-context.xml"
+        };
+    }
+    */
+    
     public void testParser() throws Exception {
         LoggingProcessor processor = new LoggingProcessor();
         String xml = processor.render(applicationContext.getBeanFactory());

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml?rev=699344&r1=699343&r2=699344&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml Fri Sep 26 07:44:56 2008
@@ -70,9 +70,9 @@
                 <gshell:message-source class="org.apache.geronimo.gshell.wisdom.command.CommandMessageSource"/>
             </gshell:command>
 
-            <gshell:alias name="foo" target="bar"/>
+            <gshell:alias name="foo" alias="bar"/>
 
-            <gshell:alias name="bar" target="foo">
+            <gshell:alias name="bar" alias="foo">
                 <description>
                     This is a test alias.
                 </description>
@@ -80,4 +80,18 @@
         </gshell:command-bundle>
     </gshell:plugin>
 
+    <!--
+    Need to define the pluginTemplate bean here, since plugin's are top-level and spring tries to validate it.
+    -->
+    
+    <bean id="pluginTemplate" class="org.apache.geronimo.gshell.wisdom.plugin.PluginImpl" abstract="true">
+        <property name="activationRules">
+            <list>
+                <bean class="org.apache.geronimo.gshell.wisdom.plugin.activation.DefaultCommandBundleActivationRule">
+                    <property name="bundleName" value="default"/>
+                </bean>
+            </list>
+        </property>
+    </bean>
+
 </beans>
\ No newline at end of file



Mime
View raw message