geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r699638 - in /geronimo/gshell/trunk: gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/ gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ gshell-wisdom/gshell-wisdom-core/src/...
Date Sat, 27 Sep 2008 13:24:11 GMT
Author: jdillon
Date: Sat Sep 27 06:24:11 2008
New Revision: 699638

URL: http://svn.apache.org/viewvc?rev=699638&view=rev
Log:
More work on the plugin API

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/BundleActivationRule.java
  (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultBundleActivationRule.java
  (contents, props changed)
      - copied, changed from r699621, 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/NoSuchBundleException.java
  (contents, props changed)
      - copied, changed from r699621, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java
Removed:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java
Modified:
    geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
    geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.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
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationContext.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationRule.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationTask.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/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml

Modified: geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
(original)
+++ geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
Sat Sep 27 06:24:11 2008
@@ -20,19 +20,21 @@
 package org.apache.geronimo.gshell.application.plugin;
 
 /**
- * ???
+ * Plugin.
  *
  * @version $Rev$ $Date$
  */
 public interface Plugin
 {
-    String getId();
+    String getName();
 
-    // TODO: Expose configured bundle names
-    
-    void activate();
+    /*
+    boolean isEnabled();
 
-    // TODO: enable() disable() isEnabled()
+    void enable() throws Exception;
 
-    // TODO: deactivate(), activate/deactiavate bundle?
+    void disable() throws Exception;
+    */
+    
+    void activate();
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/java/org/apache/geronimo/gshell/commands/admin/ListPluginsAction.java
Sat Sep 27 06:24:11 2008
@@ -55,7 +55,7 @@
         io.info("Found {} plugins:", plugins.size());
 
         for (Plugin plugin : plugins) {
-            io.info("    {}", plugin.getId());
+            io.info("    {}", plugin.getName());
         }
         
         return Result.SUCCESS;

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=699638&r1=699637&r2=699638&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
Sat Sep 27 06:24:11 2008
@@ -20,6 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.config;
 
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
+import org.apache.geronimo.gshell.application.plugin.Plugin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
@@ -28,6 +29,7 @@
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
 import org.springframework.beans.factory.xml.ParserContext;
@@ -48,7 +50,7 @@
 public class PluginParser
     extends AbstractBeanDefinitionParser
 {
-    private static final String ID = "id";
+    private static final String ID = ID_ATTRIBUTE;
 
     private static final String DESCRIPTION = "description";
 
@@ -240,13 +242,13 @@
 
             BeanDefinitionBuilder plugin = parsePlugin(element);
 
-            /*List<BeanDefinitionHolder> bundles =*/ parseCommandBundles(element);
+            Map<String,BeanDefinitionHolder> bundles = parseCommandBundles(element);
 
-            /*
-            for (BeanDefinitionHolder holder : bundles) {
-                // TODO: Handle registration of the bundles?
-            }
-            */
+            ManagedList bundleNames = new ManagedList();
+            // noinspection unchecked
+            bundleNames.addAll(bundles.keySet());
+
+            plugin.addPropertyValue("bundleNames", bundleNames);
 
             return plugin;
         }
@@ -257,7 +259,16 @@
             log.trace("Parse plugin; element: {}", element);
 
             BeanDefinitionBuilder plugin = BeanDefinitionBuilder.childBeanDefinition(PLUGIN_TEMPLATE);
-            plugin.addPropertyValue(ID, element.getAttribute(NAME));
+
+            String name = element.getAttribute(NAME);
+            plugin.addConstructorArgValue(name);
+
+            //
+            // FIXME: Give the Plugin bean a more meaningful ID, need to stop using AbstractBeanDefinitionParser
to do this.
+            //
+
+            // String id = Plugin.class.getName() + "#" + name;
+            // plugin.addPropertyValue(ID, id);
 
             parseAndApplyDescription(element, plugin);
 
@@ -268,25 +279,27 @@
         // <gshell:command-bundle>
         //
 
-        private List<BeanDefinitionHolder> parseCommandBundles(final Element element)
{
+        private Map<String,BeanDefinitionHolder> parseCommandBundles(final Element
element) {
             assert element != null;
 
             log.trace("Parse command bundles; element: {}", element);
 
+            Map<String,BeanDefinitionHolder> bundles = new LinkedHashMap<String,BeanDefinitionHolder>();
             List<Element> children = getChildElements(element, COMMAND_BUNDLE);
-            List<BeanDefinitionHolder> holders = new ArrayList<BeanDefinitionHolder>();
 
             for (Element child : children) {
+                String name = child.getAttribute(NAME);
                 BeanDefinitionBuilder bundle = parseCommandBundle(child);
 
                 // Generate id and register the bean
                 BeanDefinition def = bundle.getBeanDefinition();
                 String id = resolveId(child, def);
                 BeanDefinitionHolder holder = register(def, id);
-                holders.add(holder);
+
+                bundles.put(name, holder);
             }
 
-            return holders;
+            return bundles;
         }
 
         private BeanDefinitionBuilder parseCommandBundle(final Element 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=699638&r1=699637&r2=699638&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
Sat Sep 27 06:24:11 2008
@@ -20,14 +20,21 @@
 package org.apache.geronimo.gshell.wisdom.plugin;
 
 import org.apache.geronimo.gshell.application.plugin.Plugin;
+import org.apache.geronimo.gshell.spring.BeanContainer;
+import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.plugin.activation.ActivationContext;
 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.Collections;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Default implementation of {@link Plugin}.
@@ -35,24 +42,100 @@
  * @version $Rev$ $Date$
  */
 public class PluginImpl
-    implements Plugin
+    implements Plugin, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private String id;
+    private final String name;
+
+    private boolean enabled = false;
+
+    private List<String> bundleNames;
 
     private List<ActivationRule> activationRules;
 
-    public String getId() {
-        return id;
+    private BeanContainer container;
+
+    public PluginImpl(final String name) {
+        assert name != null;
+
+        this.name = name;
     }
 
-    public void setId(final String id) {
-        assert id != null;
-        
-        this.id = id;
+    public void setBeanContainer(final BeanContainer container) {
+        assert container != null;
+
+        this.container = container;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<String> getBundleNames() {
+        List<String> list = bundleNames;
+
+        if (bundleNames == null) {
+            list = Collections.emptyList();
+        }
+
+        return Collections.unmodifiableList(list);
+    }
+
+    public void setBundleNames(final List<String> bundleNames) {
+        assert bundleNames != null;
+        this.bundleNames = bundleNames;
+    }
+
+    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;
+            }
+        }
+
+        if (bundle == null) {
+            throw new NoSuchBundleException(name);
+        }
+
+        return bundle;
+    }
+
+    /*
+    public synchronized boolean isEnabled() {
+        return enabled;
     }
 
+    public synchronized void enable() throws Exception {
+        if (enabled) {
+            throw new IllegalStateException("Plugin already enabled: " + name);
+        }
+
+        log.debug("Enabling plugin: {}", name);
+
+        // TODO:
+
+        enabled = true;
+    }
+
+    public synchronized void disable() throws Exception {
+        if (!enabled) {
+            throw new IllegalStateException("Plugin not enabled: " + name);
+        }
+
+        log.debug("Disabling bundle: {}", name);
+
+        // TODO:
+
+        enabled = false;
+    }
+    */
+
     public List<ActivationRule> getActivationRules() {
         return activationRules;
     }
@@ -72,6 +155,10 @@
         ActivationContext context = new ActivationContext() {
             private List<ActivationTask> tasks = new ArrayList<ActivationTask>();
 
+            public Plugin getPlugin() {
+                return PluginImpl.this;
+            }
+
             public List<ActivationTask> getTasks() {
                 return tasks;
             }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
Sat Sep 27 06:24:11 2008
@@ -133,7 +133,7 @@
 
         plugins.add(plugin);
 
-        log.debug("Activating plugin: {}", plugin.getId());
+        log.debug("Activating plugin: {}", plugin.getName());
 
         plugin.activate();
 

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationContext.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/ActivationContext.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationContext.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationContext.java
Sat Sep 27 06:24:11 2008
@@ -19,15 +19,19 @@
 
 package org.apache.geronimo.gshell.wisdom.plugin.activation;
 
+import org.apache.geronimo.gshell.application.plugin.Plugin;
+
 import java.util.List;
 
 /**
- * ???
+ * Provides the context for activation rule processing.
  *
  * @version $Rev$ $Date$
  */
 public interface ActivationContext
 {
+    Plugin getPlugin();
+    
     List<ActivationTask> getTasks();
 
     void addTask(ActivationTask task);

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationRule.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/ActivationRule.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationRule.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationRule.java
Sat Sep 27 06:24:11 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.plugin.activation;
 
 /**
- * ???
+ * An activation rule.  Rules optionally add tasks to the context to perform some action.
  *
  * @version $Rev$ $Date$
  */

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationTask.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/ActivationTask.java?rev=699638&r1=699637&r2=699638&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationTask.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/ActivationTask.java
Sat Sep 27 06:24:11 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.plugin.activation;
 
 /**
- * ???
+ * An activation task, which is the basic unit of operation for "active" bits.
  *
  * @version $Rev$ $Date$
  */

Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/BundleActivationRule.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/BundleActivationRule.java?rev=699638&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/BundleActivationRule.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/BundleActivationRule.java
Sat Sep 27 06:24:11 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.plugin.activation;
+
+import org.apache.geronimo.gshell.wisdom.plugin.PluginImpl;
+import org.apache.geronimo.gshell.wisdom.plugin.bundle.Bundle;
+
+/**
+ * Activation rule which will enable a named-bundle.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BundleActivationRule
+    implements ActivationRule
+{
+    private String bundleName;
+
+    public String getBundleName() {
+        return bundleName;
+    }
+
+    public void setBundleName(final String bundleName) {
+        assert bundleName != null;
+
+        this.bundleName = bundleName;
+    }
+
+    public void evaluate(final ActivationContext context) throws Exception {
+        assert context != null;
+
+        ActivationTask task = new ActivationTask() {
+            public void execute() throws Exception {
+                PluginImpl plugin = (PluginImpl) context.getPlugin();
+                Bundle bundle = plugin.getBundle(bundleName);
+                bundle.enable();
+            }
+        };
+
+        context.addTask(task);
+    }
+}
\ No newline at end of file

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

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

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultBundleActivationRule.java
(from r699621, 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/DefaultBundleActivationRule.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultBundleActivationRule.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java&r1=699621&r2=699638&rev=699638&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/DefaultBundleActivationRule.java
Sat Sep 27 06:24:11 2008
@@ -19,79 +19,19 @@
 
 package org.apache.geronimo.gshell.wisdom.plugin.activation;
 
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-
 /**
- * ???
+ * Activation rule which will enable a named-bundle only if no other activation rules have
added tasks.
  *
  * @version $Rev$ $Date$
  */
-public class DefaultCommandBundleActivationRule
-    implements ActivationRule, BeanContainerAware
+public class DefaultBundleActivationRule
+    extends BundleActivationRule
 {
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    private BeanContainer container;
-
-    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;
-
-        this.container = container;
-    }
-
-    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;
-            }
-        }
-
-        if (bundle == null) {
-            throw new RuntimeException("No bundle found with name: " + bundleName);
-        }
-
-        return bundle;
-    }
-
     public void evaluate(final ActivationContext context) throws Exception {
         assert context != null;
 
         if (context.getTasks().isEmpty()) {
-            ActivationTask task = new ActivationTask() {
-                public void execute() throws Exception {
-                    CommandBundle bundle = getBundle();
-                    
-                    log.debug("Processing command bundle: {}", bundle);
-
-                    bundle.enable();
-                }
-            };
-
-            context.addTask(task);
+            super.evaluate(context);
         }
     }
 }
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultBundleActivationRule.java
------------------------------------------------------------------------------
    svn:executable = *

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

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/NoSuchBundleException.java
(from r699621, 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/NoSuchBundleException.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/NoSuchBundleException.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java&r1=699621&r2=699638&rev=699638&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/NoSuchBundleException.java
Sat Sep 27 06:24:11 2008
@@ -19,18 +19,19 @@
 
 package org.apache.geronimo.gshell.wisdom.plugin.bundle;
 
+import org.apache.geronimo.gshell.command.CommandException;
+
 /**
- * Plugin bundle.
+ * Thrown to indicate an operation requested an undefined named-bundle.
  *
  * @version $Rev$ $Date$
  */
-public interface Bundle
+public class NoSuchBundleException
+    extends CommandException
 {
-    String getName();
-
-    boolean isEnabled();
-
-    void enable() throws Exception;
+    private static final long serialVersionUID = 1;
 
-    void disable() throws Exception;
+    public NoSuchBundleException(final String msg) {
+        super(msg);
+    }
 }
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/NoSuchBundleException.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/plugin/bundle/NoSuchBundleException.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/NoSuchBundleException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=699638&r1=699637&r2=699638&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
Sat Sep 27 06:24:11 2008
@@ -46,7 +46,7 @@
     <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">
+                <bean class="org.apache.geronimo.gshell.wisdom.plugin.activation.DefaultBundleActivationRule">
                     <property name="bundleName" value="default"/>
                 </bean>
             </list>

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=699638&r1=699637&r2=699638&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
Sat Sep 27 06:24:11 2008
@@ -32,7 +32,7 @@
             This is a test plugin.
         </description>
         
-        <gshell:command-bundle name="test">
+        <gshell:command-bundle name="default">
             <description>
                 This is a test bundle.
             </description>
@@ -96,6 +96,22 @@
                 </description>
             </gshell:alias>
         </gshell:command-bundle>
+
+        <gshell:command-bundle name="test">
+            <description>
+                This is a test bundle.
+            </description>
+
+            <gshell:alias name="1" alias="2"/>
+
+            <gshell:command name="a">
+                <description>
+                    This is a test command.
+                </description>
+
+                <gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
+            </gshell:command>
+        </gshell:command-bundle>
     </gshell:plugin>
 
     <!--
@@ -105,7 +121,7 @@
     <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">
+                <bean class="org.apache.geronimo.gshell.wisdom.plugin.activation.DefaultBundleActivationRule">
                     <property name="bundleName" value="default"/>
                 </bean>
             </list>



Mime
View raw message