You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/20 08:05:35 UTC

svn commit: r706127 - in /geronimo/gshell/trunk: gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/ gshell-wisdom/gshell-w...

Author: jdillon
Date: Sun Oct 19 23:05:34 2008
New Revision: 706127

URL: http://svn.apache.org/viewvc?rev=706127&view=rev
Log:
Optimize bundle lookup

Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.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/PluginImpl.java

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=706127&r1=706126&r2=706127&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 Sun Oct 19 23:05:34 2008
@@ -94,6 +94,10 @@
             maxNameLen = Math.max(len, maxNameLen);
         }
 
+        //
+        // TODO: Sort the list
+        //
+
         IO io = context.getIo();
         io.out.println("Available commands:");
         for (Command command : commands) {

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=706127&r1=706126&r2=706127&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 Sun Oct 19 23:05:34 2008
@@ -274,12 +274,13 @@
             BeanDefinitionBuilder plugin = parsePlugin(element);
 
             Map<String,BeanDefinitionHolder> bundles = parseCommandBundles(element);
-
-            ManagedList bundleNames = new ManagedList();
-            // noinspection unchecked
-            bundleNames.addAll(bundles.keySet());
-
-            plugin.addPropertyValue("bundleNames", bundleNames);
+                
+            ManagedMap bundleIdMap = new ManagedMap();
+            for (Map.Entry<String,BeanDefinitionHolder> entry : bundles.entrySet()) {
+                // noinspection unchecked
+                bundleIdMap.put(entry.getKey(), entry.getValue().getBeanName());
+            }
+            plugin.addPropertyValue("bundleIdMap", bundleIdMap);
 
             return plugin;
         }
@@ -345,10 +346,6 @@
             bundle.setLazyInit(true);
             parseAndApplyDescription(element, bundle);
 
-            //
-            // TODO: Figure out how we can save the order of <gshell:command> and <gshell:link> so that 'help' displays them in the order they are defined
-            //
-
             ManagedList commands = new ManagedList();
             // noinspection unchecked
             commands.addAll(parseCommands(element));

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java?rev=706127&r1=706126&r2=706127&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java Sun Oct 19 23:05:34 2008
@@ -28,12 +28,12 @@
 import org.apache.geronimo.gshell.wisdom.plugin.activation.ActivationRule;
 import org.apache.geronimo.gshell.wisdom.plugin.activation.ActivationTask;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.Bundle;
-import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.NoSuchBundleException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -58,7 +58,7 @@
 
     private ClassPath classPath;
 
-    private List<String> bundleNames;
+    private Map<String,String> bundleIdMap;
 
     private List<ActivationRule> activationRules;
 
@@ -106,38 +106,35 @@
         this.classPath = classPath;
     }
     
-    public List<String> getBundleNames() {
-        List<String> list = bundleNames;
+    public Collection<String> getBundleNames() {
+        Collection<String> names;
 
-        if (bundleNames == null) {
-            list = Collections.emptyList();
+        if (bundleIdMap == null) {
+            names = Collections.emptyList();
+        }
+        else {
+            names = bundleIdMap.keySet();
         }
 
-        return Collections.unmodifiableList(list);
+        return Collections.unmodifiableCollection(names);
     }
 
-    public void setBundleNames(final List<String> bundleNames) {
-        assert bundleNames != null;
-        this.bundleNames = bundleNames;
+    public void setBundleIdMap(final Map<String, String> bundleIdMap) {
+        assert bundleIdMap != null;
+        this.bundleIdMap = bundleIdMap;
     }
 
     public Bundle getBundle(final String name) throws NoSuchBundleException {
-        assert container != null;
-        Map<String, CommandBundle> bundles = container.getBeans(CommandBundle.class);
-
-        CommandBundle bundle = null;
-        for (CommandBundle b : bundles.values()) {
-            if (b.getName().equals(name)) {
-                bundle = b;
-                break;
-            }
-        }
+        assert name != null;
+        assert bundleIdMap != null;
+        String id = bundleIdMap.get(name);
 
-        if (bundle == null) {
+        if (id == null) {
             throw new NoSuchBundleException(name);
         }
 
-        return bundle;
+        assert container != null;
+        return container.getBean(id, Bundle.class);
     }
 
     /*