geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r695399 - in /geronimo/gshell/trunk: gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-support/gshell-event/ gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/ gshell...
Date Mon, 15 Sep 2008 09:52:08 GMT
Author: jdillon
Date: Mon Sep 15 02:52:07 2008
New Revision: 695399

URL: http://svn.apache.org/viewvc?rev=695399&view=rev
Log:
Using gshell-event instead of spring event stuff
Dropped event stuff from the BeanContainer interface

Added:
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java   (contents, props changed)
      - copied, changed from r695376, geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java
Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
    geronimo/gshell/trunk/gshell-support/gshell-event/pom.xml
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/Event.java
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventListener.java
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventPublisher.java
    geronimo/gshell/trunk/gshell-support/gshell-event/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainer.java
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationConfiguredEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsConfiguredEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ShellCreatedEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilder.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilderImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerManager.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerRegisteredEvent.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginLoadedEvent.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/shell/HistoryImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java Mon Sep 15 02:52:07 2008
@@ -19,14 +19,11 @@
 
 package org.apache.geronimo.gshell.commands.builtins;
 
-import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * Display help
@@ -38,135 +35,12 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Autowired
-    private ApplicationManager applicationManager;
-
     @Argument(metaVar="COMMAND", required=true)
     private String command;
 
-    private Renderer renderer = new Renderer();
-
-    public HelpCommand() {}
-
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;
 
-        /*
-        if (command == null) {
-            displayAvailableCommands(context);
-        }
-        else {
-            displayCommandManual(context.getIo(), command, context.getVariables());
-        }
-        */
-
-        if (true) throw new Error();
-        
-        return Result.SUCCESS;
-    }
-
-    /*
-    private void displayAvailableCommands(final CommandContext context) throws Exception {
-        assert context != null;
-
-        IO io = context.getIo();
-        String about = applicationManager.getApplication().getModel().getBranding().getAboutMessage();
-
-        if (about != null) {
-            io.out.print(about);
-            io.out.println();
-        }
-
-        io.out.println("Available commands:");
-
-        GroupNode group = layoutManager.getLayout();
-
-        displayGroupCommands(io, group, context.getVariables());
-    }
-
-    private void displayGroupCommands(final IO io, final GroupNode group, final Variables variables) throws Exception {
-        assert io != null;
-        int maxNameLen = 20; // FIXME: Figure this out dynamically
-
-        // First display command/aliases nodes
-        for (Node child : group.nodes()) {
-            log.debug("Render help tree for node: {}", child);
-            
-            if (child instanceof CommandNode) {
-                String path = child.getPath();
-
-                log.debug("Resolving command for path: {}", path);
-
-                Command command = commandResolver.resolve(variables, path);
-                String name = StringUtils.rightPad(child.getName(), maxNameLen);
-
-                CommandDocumenter documenter = command.getContainer().getDocumenter();
-                String desc = documenter.getDescription();
-
-                io.out.print("  ");
-                io.out.print(renderer.render(Renderer.encode(name, Code.BOLD)));
-
-                if (desc != null) {
-                    io.out.print("  ");
-                    io.out.println(desc);
-                }
-                else {
-                    io.out.println();
-                }
-            }
-            else if (child instanceof AliasNode) {
-                AliasNode node = (AliasNode) child;
-                String name = StringUtils.rightPad(node.getName(), maxNameLen);
-
-                io.out.print("  ");
-                io.out.print(renderer.render(Renderer.encode(name, Code.BOLD)));
-                io.out.print("  ");
-
-                io.out.print("Alias to: ");
-                io.out.println(renderer.render(Renderer.encode(node.getCommand(), Code.BOLD)));
-            }
-        }
-
-        io.out.println();
-
-        // Then groups
-        for (Node child : group.nodes()) {
-            if (child instanceof GroupNode) {
-                GroupNode node = (GroupNode) child;
-
-                String path = node.getPath();
-                
-                //
-                // HACK: Until we get / and ../ stuff working, we have to strip off the leading "/"
-                //
-                //       https://issues.apache.org/jira/browse/GSHELL-86
-                //
-                if (path != null && path.startsWith("/")) {
-                    path = path.substring(1, path.length());
-                }
-                
-                io.out.print("  ");
-                io.out.println(renderer.render(Renderer.encode(path, Code.BOLD)));
-
-                io.out.println();
-                displayGroupCommands(io, node, variables);
-                io.out.println();
-            }
-        }
-    }
-
-    private void displayCommandManual(final IO io, final String path, final Variables variables) throws CommandException {
-        assert path != null;
-        assert variables != null;
-
-        Command command = commandResolver.resolve(variables, path);
-
-        CommandDocumenter documenter = command.getContainer().getDocumenter();
-        CommandInfo info = command.getInfo();
-
-        log.debug("Rendering help for command: {}", info.getName());
-
-        documenter.renderManual(info, io.out);
+        throw new Error("Not implemented");
     }
-    */
 }

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/pom.xml?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/pom.xml Mon Sep 15 02:52:07 2008
@@ -37,4 +37,22 @@
         Event support for GShell components.
     </description>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-yarn</artifactId>
+        </dependency>
+    </dependencies>
+
 </project>
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/Event.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/Event.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/Event.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/Event.java Mon Sep 15 02:52:07 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.event;
 
 /**
- * ???
+ * Marks a class as an event container.
  *
  * @version $Rev$ $Date$
  */

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventListener.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventListener.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventListener.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventListener.java Mon Sep 15 02:52:07 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.event;
 
 /**
- * ???
+ * Provides access to published events.
  *
  * @version $Rev$ $Date$
  */

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java Mon Sep 15 02:52:07 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.event;
 
 /**
- * ???
+ * Manages event subscriptions.
  *
  * @version $Rev$ $Date$
  */

Copied: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java (from r695376, geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java?p2=geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java&p1=geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java&r1=695376&r2=695399&rev=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManager.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java Mon Sep 15 02:52:07 2008
@@ -19,16 +19,76 @@
 
 package org.apache.geronimo.gshell.event;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.LinkedHashSet;
+
 /**
- * ???
+ * The default {@link EventManager} and {@link EventPublisher} components.
  *
  * @version $Rev$ $Date$
  */
-public interface EventManager
+public class EventManagerImpl
+    implements EventManager, EventPublisher
 {
-    void addListener(EventListener listener);
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final Set<EventListener> listeners = new LinkedHashSet<EventListener>();
+
+    //
+    // EventManager
+    //
+
+    public void addListener(final EventListener listener) {
+        assert listener != null;
+
+        log.debug("Adding listener: {}", listener);
+
+        synchronized (listeners) {
+            listeners.add(listener);
+        }
+    }
+
+    public void removeListneer(final EventListener listener) {
+        assert listener != null;
+        
+        log.debug("Removing listener: {}", listener);
+
+        synchronized (listeners) {
+            listeners.remove(listener);
+        }
+    }
+
+    public EventPublisher getPublisher() {
+        return this;
+    }
+
+    //
+    // EventPublisher
+    //
+
+    public void publish(final Event event) {
+        assert event != null;
+
+        log.debug("Publishing event: {}", event);
+
+        EventListener[] targets;
+        
+        synchronized (listeners) {
+            targets = listeners.toArray(new EventListener[listeners.size()]);
+        }
 
-    void removeListneer(EventListener listener);
+        for (EventListener listener : targets) {
+            log.trace("Firing event ({}) to listener: {}", event, listener);
 
-    EventPublisher getPublisher();
+            try {
+                listener.onEvent(event);
+            }
+            catch (Exception e) {
+                log.error("Listener handler raised an exception", e);
+            }
+        }
+    }
 }
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java
------------------------------------------------------------------------------
    svn:executable = *

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

Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventManagerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventPublisher.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventPublisher.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventPublisher.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventPublisher.java Mon Sep 15 02:52:07 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.event;
 
 /**
- * ???
+ * Allows publishing of events.
  *
  * @version $Rev$ $Date$
  */

Modified: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/resources/META-INF/spring/components.xml?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/resources/META-INF/spring/components.xml Mon Sep 15 02:52:07 2008
@@ -29,8 +29,6 @@
 
     <context:annotation-config/>
 
-    <!--
     <bean id="eventManager" class="org.apache.geronimo.gshell.event.EventManagerImpl"/>
-    -->
-
+    
 </beans>
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainer.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainer.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainer.java Mon Sep 15 02:52:07 2008
@@ -20,10 +20,8 @@
 
 package org.apache.geronimo.gshell.spring;
 
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
 import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
+import org.springframework.beans.BeansException;
 
 import java.net.URL;
 import java.util.List;
@@ -41,9 +39,5 @@
 
     <T> T getBean(String name, Class<T> requiredType) throws BeansException;
 
-    void publish(ApplicationEvent event);
-
-    void addListener(ApplicationListener listener);
-
     BeanContainer createChild(String id, List<URL> classPath) throws DuplicateRealmException;
 }

Modified: geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java Mon Sep 15 02:52:07 2008
@@ -20,24 +20,23 @@
 
 package org.apache.geronimo.gshell.spring;
 
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.context.ApplicationListener;
-import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.FatalBeanException;
+import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.List;
 import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * Custom Spring {@link org.springframework.context.ApplicationContext} for {@link BeanContainer} instances.
@@ -107,13 +106,6 @@
         return list.toArray(new Resource[list.size()]);
     }
 
-    @Override
-    public void addListener(final ApplicationListener listener) {
-        assert listener != null;
-        
-        super.addListener(listener);
-    }
-
     public void addBeanPostProcessor(final BeanPostProcessor processor) {
         assert processor != null;
 

Modified: geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java Mon Sep 15 02:52:07 2008
@@ -26,12 +26,10 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
 
 import java.net.URL;
-import java.util.List;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * Default {@link BeanContainer} implementation.
@@ -86,6 +84,8 @@
         // Construct the container and add customizations
         context = new BeanContainerContext(classRealm, parent != null ? parent.context : null);
         context.registerShutdownHook();
+
+        // TODO: Configure this in components.xml ?
         context.addBeanPostProcessor(new BeanContainerAwareProcessor(this));
 
         // Refresh to load things up
@@ -122,23 +122,6 @@
         return (T) context.getBean(name, requiredType);
     }
 
-    public void publish(final ApplicationEvent event) {
-        assert event != null;
-
-        log.debug("Publishing event: {}", event);
-        
-        context.publishEvent(event);
-    }
-
-    public void addListener(final ApplicationListener listener) {
-        assert listener != null;
-
-        log.debug("Adding listener: {}", listener);
-
-        // addApplicationListener() only adds listeners before refresh(), so use addListener()
-        context.addListener(listener);
-    }
-
     public BeanContainer createChild(final String id, final List<URL> classPath) throws DuplicateRealmException {
         assert id != null;
         assert classPath != null;

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationConfiguredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationConfiguredEvent.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationConfiguredEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationConfiguredEvent.java Mon Sep 15 02:52:07 2008
@@ -19,9 +19,8 @@
 
 package org.apache.geronimo.gshell.wisdom.application;
 
-import org.springframework.context.ApplicationEvent;
-import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.application.Application;
+import org.apache.geronimo.gshell.event.Event;
 
 /**
  * Event fired once the application has been configured.
@@ -29,17 +28,17 @@
  * @version $Rev$ $Date$
  */
 public class ApplicationConfiguredEvent
-    extends ApplicationEvent
+    implements Event
 {
-    public ApplicationConfiguredEvent(final ApplicationManager source) {
-        super(source);
-    }
+    private final Application application;
+    
+    public ApplicationConfiguredEvent(final Application application) {
+        assert application != null;
 
-    public ApplicationManager getApplicationManager() {
-        return (ApplicationManager) getSource();
+        this.application = application;
     }
 
     public Application getApplication() {
-        return getApplicationManager().getApplication();
+        return application;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java Mon Sep 15 02:52:07 2008
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
 import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.event.EventPublisher;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
 import org.apache.geronimo.gshell.model.common.Dependency;
@@ -37,8 +38,6 @@
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
-import org.apache.geronimo.gshell.wisdom.application.ShellCreatedEvent;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -77,6 +76,9 @@
 
     @Autowired
     private SettingsManager settingsManager;
+
+    @Autowired
+    private EventPublisher eventPublisher;
     
     private BeanContainer container;
 
@@ -133,7 +135,7 @@
 
         log.debug("Application configured");
         
-        applicationContainer.publish(new ApplicationConfiguredEvent(this));
+        eventPublisher.publish(new ApplicationConfiguredEvent(application));
     }
 
     private void interpolate(final ApplicationConfiguration config) throws Exception {
@@ -358,7 +360,7 @@
 
         log.debug("Create shell proxy: {}", proxy);
 
-        applicationContainer.publish(new ShellCreatedEvent(proxy));
+        eventPublisher.publish(new ShellCreatedEvent(proxy));
         
         return proxy;
     }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsConfiguredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsConfiguredEvent.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsConfiguredEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsConfiguredEvent.java Mon Sep 15 02:52:07 2008
@@ -19,9 +19,8 @@
 
 package org.apache.geronimo.gshell.wisdom.application;
 
-import org.springframework.context.ApplicationEvent;
-import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.application.settings.Settings;
+import org.apache.geronimo.gshell.event.Event;
 
 /**
  * Event fired once settings have been configured.
@@ -29,17 +28,17 @@
  * @version $Rev$ $Date$
  */
 public class SettingsConfiguredEvent
-    extends ApplicationEvent
+    implements Event
 {
-    public SettingsConfiguredEvent(final SettingsManager source) {
-        super(source);
-    }
+    private final Settings settings;
+    
+    public SettingsConfiguredEvent(final Settings settings) {
+        assert settings != null;
 
-    public SettingsManager getSettingsManager() {
-        return (SettingsManager) getSource();
+        this.settings = settings;
     }
 
     public Settings getSettings() {
-        return getSettingsManager().getSettings();
+        return settings;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java Mon Sep 15 02:52:07 2008
@@ -19,17 +19,15 @@
 
 package org.apache.geronimo.gshell.wisdom.application;
 
+import org.apache.geronimo.gshell.application.settings.Settings;
 import org.apache.geronimo.gshell.application.settings.SettingsConfiguration;
 import org.apache.geronimo.gshell.application.settings.SettingsManager;
-import org.apache.geronimo.gshell.application.settings.Settings;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.event.EventPublisher;
 import org.apache.geronimo.gshell.model.common.RemoteRepository;
 import org.apache.geronimo.gshell.model.interpolate.Interpolator;
 import org.apache.geronimo.gshell.model.interpolate.InterpolatorSupport;
 import org.apache.geronimo.gshell.model.settings.SettingsModel;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.wisdom.application.SettingsConfiguredEvent;
 import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,25 +39,20 @@
  * @version $Rev$ $Date$
  */
 public class SettingsManagerImpl
-    implements SettingsManager, BeanContainerAware
+    implements SettingsManager
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
     private ArtifactManager artifactManager;
 
+    @Autowired
+    private EventPublisher eventPublisher;
+
     private SettingsConfiguration settingsConfiguration;
 
     private Settings settings;
 
-    private BeanContainer container;
-
-    public void setBeanContainer(final BeanContainer container) {
-        assert container != null;
-
-        this.container = container;
-    }
-
     public Settings getSettings() {
         if (settings == null) {
             throw new IllegalStateException("Not configured");
@@ -97,7 +90,7 @@
 
         log.debug("Settings configured");
 
-        container.publish(new SettingsConfiguredEvent(this));
+        eventPublisher.publish(new SettingsConfiguredEvent(settings));
     }
 
     private void interpolate(final SettingsConfiguration config) throws Exception {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ShellCreatedEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ShellCreatedEvent.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ShellCreatedEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ShellCreatedEvent.java Mon Sep 15 02:52:07 2008
@@ -19,8 +19,8 @@
 
 package org.apache.geronimo.gshell.wisdom.application;
 
+import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.shell.Shell;
-import org.springframework.context.ApplicationEvent;
 
 /**
  * Event fired once the application has constructed a shell.
@@ -28,13 +28,17 @@
  * @version $Rev$ $Date$
  */
 public class ShellCreatedEvent
-    extends ApplicationEvent
+    implements Event
 {
-    public ShellCreatedEvent(final Shell source) {
-        super(source);
+    private final Shell shell;
+    
+    public ShellCreatedEvent(final Shell shell) {
+        assert shell != null;
+
+        this.shell = shell;
     }
 
     public Shell getShell() {
-        return (Shell) getSource();
+        return shell;
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilder.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilder.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilder.java Mon Sep 15 02:52:07 2008
@@ -19,14 +19,14 @@
 
 package org.apache.geronimo.gshell.wisdom.builder;
 
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.shell.ShellFactory;
-import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.application.settings.SettingsManager;
+import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
 import org.apache.geronimo.gshell.model.settings.SettingsModel;
-import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.shell.ShellFactory;
 
 /**
  * Builds {@link org.apache.geronimo.gshell.shell.Shell} instanes.

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilderImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilderImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/builder/ShellBuilderImpl.java Mon Sep 15 02:52:07 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
 import org.apache.geronimo.gshell.artifact.monitor.ProgressSpinnerMonitor;
+import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.io.SystemOutputHijacker;
@@ -33,7 +34,6 @@
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerImpl;
-import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerManager.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerManager.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerManager.java Mon Sep 15 02:52:07 2008
@@ -26,10 +26,10 @@
 import org.apache.geronimo.gshell.command.CommandException;
 import org.apache.geronimo.gshell.command.CommandNotFoundException;
 import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.geronimo.gshell.event.EventPublisher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -40,23 +40,14 @@
  * @version $Rev$ $Date$
  */
 public class CommandContainerManager
-    implements BeanContainerAware, CommandContainerRegistry, CommandContainerFactory, CommandContainerResolver
+    implements CommandContainerRegistry, CommandContainerFactory, CommandContainerResolver
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private BeanContainer beanContainer;
-    
-    private Map<String,CommandContainer> registrations = new HashMap<String,CommandContainer>();
+    @Autowired
+    private EventPublisher eventPublisher;
 
-    //
-    // BeanContainerAware
-    //
-    
-    public void setBeanContainer(final BeanContainer container) {
-        assert container != null;
-
-        this.beanContainer = container;
-    }
+    private Map<String,CommandContainer> registrations = new HashMap<String,CommandContainer>();
 
     //
     // CommandContainerRegistry
@@ -71,7 +62,7 @@
         
         registrations.put(id, container);
 
-        beanContainer.publish(new CommandContainerRegisteredEvent(this, container));
+        eventPublisher.publish(new CommandContainerRegisteredEvent(container));
     }
 
     //

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerRegisteredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerRegisteredEvent.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerRegisteredEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandContainerRegisteredEvent.java Mon Sep 15 02:52:07 2008
@@ -20,7 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.command;
 
 import org.apache.geronimo.gshell.command.CommandContainer;
-import org.springframework.context.ApplicationEvent;
+import org.apache.geronimo.gshell.event.Event;
 
 /**
  * Event fired once a command container has been registered.
@@ -28,12 +28,12 @@
  * @version $Rev$ $Date$
  */
 public class CommandContainerRegisteredEvent
-    extends ApplicationEvent
+    implements Event
 {
-    private CommandContainer container;
+    private final CommandContainer container;
 
-    public CommandContainerRegisteredEvent(final CommandContainerManager source, final CommandContainer container) {
-        super(source);
+    public CommandContainerRegisteredEvent(final CommandContainer container) {
+        assert container != null;
 
         this.container = container;
     }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginLoadedEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginLoadedEvent.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginLoadedEvent.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginLoadedEvent.java Mon Sep 15 02:52:07 2008
@@ -21,6 +21,7 @@
 
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.model.application.Plugin;
+import org.apache.geronimo.gshell.event.Event;
 import org.springframework.context.ApplicationEvent;
 
 /**
@@ -29,20 +30,16 @@
  * @version $Rev$ $Date$
  */
 public class PluginLoadedEvent
-    extends ApplicationEvent
+    implements Event
 {
-    private Plugin plugin;
+    private final Plugin plugin;
 
-    public PluginLoadedEvent(final PluginManager source, final Plugin plugin) {
-        super(source);
+    public PluginLoadedEvent(final Plugin plugin) {
+        assert plugin != null;
 
         this.plugin = plugin;
     }
 
-    public PluginManager getPluginManager() {
-        return (PluginManager)getSource();
-    }
-
     public Plugin getPlugin() {
         return plugin;
     }

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=695399&r1=695398&r2=695399&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 Mon Sep 15 02:52:07 2008
@@ -22,6 +22,10 @@
 import org.apache.geronimo.gshell.application.Application;
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.event.EventPublisher;
+import org.apache.geronimo.gshell.event.EventManager;
+import org.apache.geronimo.gshell.event.EventListener;
+import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.model.application.Plugin;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
@@ -36,9 +40,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
 
+import javax.annotation.PostConstruct;
 import java.io.File;
 import java.net.URL;
 import java.util.LinkedHashSet;
@@ -52,13 +55,19 @@
  * @version $Rev$ $Date$
  */
 public class PluginManagerImpl
-    implements PluginManager, BeanContainerAware, ApplicationListener
+    implements PluginManager, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
     private ArtifactManager artifactManager;
 
+    @Autowired
+    private EventManager eventManager;
+
+    @Autowired
+    private EventPublisher eventPublisher;
+
     private BeanContainer container;
 
     public void setBeanContainer(final BeanContainer container) {
@@ -67,16 +76,21 @@
         this.container = container;
     }
 
-    public void onApplicationEvent(final ApplicationEvent event) {
-        assert event != null;
+    @PostConstruct
+    public void init() {
+        eventManager.addListener(new EventListener() {
+            public void onEvent(Event event) throws Exception {
+                assert event != null;
 
-        if (event instanceof ApplicationConfiguredEvent) {
-            ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
+                if (event instanceof ApplicationConfiguredEvent) {
+                    ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
 
-            loadPlugins(targetEvent.getApplication());
-        }
+                    loadPlugins(targetEvent.getApplication());
+                }
+            }
+        });
     }
-
+    
     private void loadPlugins(final Application application) {
         assert application != null;
 
@@ -103,7 +117,9 @@
 
         BeanContainer pluginContainer = container.createChild("gshell.plugin[" + plugin.getId() + "]", classPath);
 
-        pluginContainer.publish(new PluginLoadedEvent(this, plugin));
+        log.debug("Created plugin container: {}", pluginContainer);
+        
+        eventPublisher.publish(new PluginLoadedEvent(plugin));
     }
 
     private List<URL> createClassPath(final Plugin plugin) throws Exception {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java Mon Sep 15 02:52:07 2008
@@ -20,12 +20,15 @@
 package org.apache.geronimo.gshell.wisdom.shell;
 
 import jline.History;
-import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.geronimo.gshell.event.EventManager;
+import org.apache.geronimo.gshell.event.EventListener;
+import org.apache.geronimo.gshell.event.Event;
+import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
 
+import javax.annotation.PostConstruct;
 import java.io.File;
 import java.io.IOException;
 
@@ -36,40 +39,44 @@
  */
 public class HistoryImpl
     extends History
-    implements ApplicationListener
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    public HistoryImpl() {}
+    @Autowired
+    private EventManager eventManager;
 
-    public void onApplicationEvent(final ApplicationEvent event) {
-        assert event != null;
+    @PostConstruct
+    public void init() {
+        eventManager.addListener(new EventListener() {
+            public void onEvent(Event event) throws Exception {
+                assert event != null;
 
-        if (event instanceof ApplicationConfiguredEvent) {
-            ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
+                if (event instanceof ApplicationConfiguredEvent) {
+                    ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
 
-            try {
-                File file = targetEvent.getApplication().getModel().getBranding().getHistoryFile();
+                    File file = targetEvent.getApplication().getModel().getBranding().getHistoryFile();
 
-                log.debug("Application configured, setting history file: {}", file);
+                    log.debug("Application configured, setting history file: {}", file);
 
-                setHistoryFile(file);
+                    setHistoryFile(file);
+                }
             }
-            catch (IOException e) {
-                throw new RuntimeException("Failed to set history file", e);
-            }
-        }
+        });
     }
-
+    
     public void setHistoryFile(final File file) throws IOException {
         assert file != null;
 
         File dir = file.getParentFile();
 
         if (!dir.exists()) {
-            dir.mkdirs();
-
-            log.debug("Created base directory for history file: {}", dir);
+            boolean result = dir.mkdirs();
+            if (!result) {
+                log.warn("Failed to create base directory for history file: {}", dir);
+            }
+            else {
+                log.debug("Created base directory for history file: {}", dir);
+            }
         }
 
         log.debug("Using history file: {}", file);

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=695399&r1=695398&r2=695399&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java Mon Sep 15 02:52:07 2008
@@ -21,7 +21,6 @@
 
 import jline.History;
 import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.application.Application;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
 import org.apache.geronimo.gshell.console.Console;
@@ -34,14 +33,17 @@
 import org.apache.geronimo.gshell.notification.ExitNotification;
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.shell.ShellInfo;
+import org.apache.geronimo.gshell.event.EventManager;
+import org.apache.geronimo.gshell.event.EventListener;
+import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
+import org.apache.geronimo.gshell.application.Application;
 import org.codehaus.plexus.util.IOUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
 
+import javax.annotation.PostConstruct;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -53,11 +55,14 @@
  * @version $Rev$ $Date$
  */
 public class ShellImpl
-    implements Shell, ApplicationListener
+    implements Shell
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
+    private EventManager eventManager;
+
+    @Autowired
     private ShellInfo shellInfo;
 
     @Autowired
@@ -76,8 +81,6 @@
 
     private ErrorHandler errorHandler;
 
-    public ShellImpl() {}
-
     public IO getIo() {
         return io;
     }
@@ -98,29 +101,29 @@
         return true;
     }
 
-    public void onApplicationEvent(final ApplicationEvent event) {
-        assert event != null;
-
-        if (event instanceof ApplicationConfiguredEvent) {
-            ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
+    @PostConstruct
+    public void init() {
+        eventManager.addListener(new EventListener() {
+            public void onEvent(Event event) throws Exception {
+                assert event != null;
+
+                if (event instanceof ApplicationConfiguredEvent) {
+                    ApplicationConfiguredEvent targetEvent = (ApplicationConfiguredEvent)event;
+
+                    log.debug("Binding application io/variables/branding from context");
+
+                    // Dereference some bits from the applciation context
+                    Application application = targetEvent.getApplication();
+                    io = application.getIo();
+                    variables = application.getVariables();
+                    branding = application.getModel().getBranding();
 
-            log.debug("Binding application io/variables/branding from context");
-            
-            // Dereference some bits from the applciation context
-            Application context = targetEvent.getApplication();
-            io = context.getIo();
-            variables = context.getVariables();
-            branding = context.getModel().getBranding();
-
-            try {
-                loadProfileScripts();
-            }
-            catch (Exception e) {
-                throw new RuntimeException(e.getMessage(), e);
+                    loadProfileScripts();
+                }
             }
-        }
+        });
     }
-
+    
     //
     // Interactive Shell
     //
@@ -320,6 +323,8 @@
     private void loadProfileScripts() throws Exception {
         assert branding != null;
 
+        log.debug("Loading profile scripts");
+        
         // Load profile scripts if they exist
         loadSharedScript(branding.getProfileScriptName());
         loadUserScript(branding.getProfileScriptName());



Mime
View raw message