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/09/11 09:47:28 UTC

svn commit: r694163 - in /geronimo/gshell/trunk: gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/ gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ gshell-support/gshell-spring/src/test/resources...

Author: jdillon
Date: Thu Sep 11 00:47:27 2008
New Revision: 694163

URL: http://svn.apache.org/viewvc?rev=694163&view=rev
Log:
Almost have Spring container muck working

Added:
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java   (contents, props changed)
      - copied, changed from r694137, geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerApplicationContext.java
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml   (with props)
Removed:
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerApplicationContext.java
Modified:
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/VariableInterpolator.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/resources/META-INF/spring/components.xml

Copied: geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java (from r694137, geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerApplicationContext.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java?p2=geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java&p1=geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerApplicationContext.java&r1=694137&r2=694163&rev=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerApplicationContext.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerContext.java Thu Sep 11 00:47:27 2008
@@ -20,23 +20,91 @@
 
 package org.apache.geronimo.gshell.spring;
 
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.context.ApplicationListener;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+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.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;
 
 /**
  * Custom Spring {@link org.springframework.context.ApplicationContext} for {@link BeanContainer} instances.
  *
  * @version $Rev$ $Date$
  */
-public class BeanContainerApplicationContext
-    extends ClassPathXmlApplicationContext
+public class BeanContainerContext
+    extends GenericApplicationContext
 {
-    public BeanContainerApplicationContext(final String[] configLocations) {
-        super(configLocations, false);
+    private static final String[] CONFIG_LOCATIONS = {
+        "classpath*:META-INF/spring/components.xml"
+    };
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final Set<Resource> ownedResources = new HashSet<Resource>();
+
+    public BeanContainerContext(final ClassLoader classLoader) {
+        this(classLoader, null);
+    }
+
+    public BeanContainerContext(final ClassLoader classLoader, BeanContainerContext parent) {
+        super(parent);
+        assert classLoader != null;
+
+        setClassLoader(classLoader);
+
+        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this);
+
+        for (String location : CONFIG_LOCATIONS) {
+            Resource[] resources;
+            try {
+                resources = getResources(location);
+            }
+            catch (IOException e) {
+                throw new FatalBeanException("Failed to load resources from location: " + location, e);
+            }
+
+            if (parent != null) {
+                resources = parent.filterOwnedResources(resources);
+            }
+
+            // Track which resources we own
+            ownedResources.addAll(Arrays.asList(resources));
+            
+            reader.loadBeanDefinitions(resources);
+        }
     }
 
-    public BeanContainerApplicationContext(final String[] configLocations, BeanContainerApplicationContext parent) {
-        super(configLocations, false, parent);
+    /**
+     * Filter owned resources from the given resources list.
+     */
+    private Resource[] filterOwnedResources(final Resource[] resources) {
+        assert resources != null;
+
+        List<Resource> list = new ArrayList<Resource>();
+
+        for (Resource resource : resources) {
+            if (ownedResources.contains(resource)) {
+                log.debug("Filtered owned resource: {}", resource);
+            }
+            else {
+                list.add(resource);
+            }
+        }
+
+        return list.toArray(new Resource[list.size()]);
     }
 
     @Override
@@ -45,4 +113,31 @@
         
         super.addListener(listener);
     }
+
+    public void addBeanPostProcessor(final BeanPostProcessor processor) {
+        assert processor != null;
+
+        addBeanFactoryPostProcessor(new BeanFactoryPostProcessor()
+        {
+            public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
+                assert beanFactory != null;
+
+                beanFactory.addBeanPostProcessor(processor);
+            }
+        });
+    }
+
+    /*
+    @Override
+    protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory) {
+		// Stop using the temporary ClassLoader for type matching.
+		beanFactory.setTempClassLoader(null);
+
+		// Allow for caching all bean definition metadata, not expecting further changes.
+		beanFactory.freezeConfiguration();
+
+		// Instantiate all remaining (non-lazy-init) singletons.
+		beanFactory.preInstantiateSingletons();
+	}
+    */
 }
\ No newline at end of file

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

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

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

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

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=694163&r1=694162&r2=694163&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 Thu Sep 11 00:47:27 2008
@@ -19,18 +19,15 @@
 
 package org.apache.geronimo.gshell.spring;
 
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
 import org.codehaus.plexus.classworlds.ClassWorld;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
 import org.slf4j.Logger;
 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;
@@ -45,59 +42,51 @@
 {
     private static final String REALM_ID = "gshell";
 
-    private static final String[] CONFIG_LOCATIONS = {
-        "classpath*:META-INF/spring/components.xml",
-        "classpath*:META-INF/gshell/commands.xml"
-    };
-
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private final BeanContainer parent;
+    private BeanContainer parent;
 
-    private final BeanContainerApplicationContext context;
+    private BeanContainerContext context;
 
-    private final ClassWorld classWorld;
-
-    private final ClassRealm classRealm;
+    private ClassRealm classRealm;
     
     public BeanContainerImpl(final ClassLoader classLoader) {
         assert classLoader != null;
 
-        parent = null;
-        
-        // Setup classworlds
-        classWorld = new ClassWorld();
+        ClassRealm realm;
         try {
-            classRealm = classWorld.newRealm(REALM_ID, classLoader);
-        } catch (DuplicateRealmException e) {
+            realm = new ClassWorld().newRealm(REALM_ID, classLoader);
+        }
+        catch (DuplicateRealmException e) {
             // Should never happen
             throw new Error(e);
         }
 
-        // Construct the container and add customizations
-        context = new BeanContainerApplicationContext(CONFIG_LOCATIONS);
-        context.registerShutdownHook();
-        context.setClassLoader(classRealm);
-        addBeanPostProcessor(new BeanContainerAwareProcessor(this));
-
-        // Refresh to load things up
-        context.refresh();
+        configureContext(realm, null);
     }
 
-    private BeanContainerImpl(final BeanContainerImpl parent, final ClassRealm classRealm) {
+    /**
+     * Child container constructor.
+     */
+    private BeanContainerImpl(final ClassRealm classRealm, final BeanContainerImpl parent) {
         assert parent != null;
         assert classRealm != null;
 
+        configureContext(classRealm, parent);
+    }
+
+    private void configureContext(final ClassRealm classRealm, final BeanContainerImpl parent) {
+        assert classRealm != null;
+        // parent may be null
+
         this.parent = parent;
-        this.classWorld = classRealm.getWorld();
         this.classRealm = classRealm;
 
         // Construct the container and add customizations
-        context = new BeanContainerApplicationContext(CONFIG_LOCATIONS, parent.context);
+        context = new BeanContainerContext(classRealm, parent != null ? parent.context : null);
         context.registerShutdownHook();
-        context.setClassLoader(classRealm);
-        addBeanPostProcessor(new BeanContainerAwareProcessor(this));
-        
+        context.addBeanPostProcessor(new BeanContainerAwareProcessor(this));
+
         // Refresh to load things up
         context.refresh();
     }
@@ -106,21 +95,11 @@
         return parent;
     }
 
-    private void addBeanPostProcessor(final BeanPostProcessor processor) {
-        assert processor != null;
-
-        context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor()
-        {
-            public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
-                beanFactory.addBeanPostProcessor(processor);
-            }
-        });
-    }
-
     public <T> T getBean(final Class<T> type) throws BeansException {
         assert type != null;
 
         String[] names = context.getBeanNamesForType(type);
+
         if (names.length == 0) {
             throw new NoSuchBeanDefinitionException(type, "No bean defined for type: " + type);
         }
@@ -139,18 +118,18 @@
         return (T) context.getBean(name, requiredType);
     }
 
-    public void publish(ApplicationEvent event) {
+    public void publish(final ApplicationEvent event) {
         assert event != null;
 
-        log.debug("Publishing event: {} ({})", event, this);
+        log.debug("Publishing event: {}", event);
         
         context.publishEvent(event);
     }
 
-    public void addListener(ApplicationListener listener) {
+    public void addListener(final ApplicationListener listener) {
         assert listener != null;
 
-        log.debug("Adding listener: {} ({})", listener, this);
+        log.debug("Adding listener: {}", listener);
 
         // addApplicationListener() only adds listeners before refresh(), so use addListener()
         context.addListener(listener);
@@ -160,7 +139,7 @@
         assert id != null;
         assert classPath != null;
 
-        log.debug("Creating child bean container: " + id);
+        log.debug("Creating child container: {}", id);
         
         ClassRealm childRealm = classRealm.createChildRealm(id);
 
@@ -168,6 +147,6 @@
             childRealm.addURL(url);
         }
 
-        return new BeanContainerImpl(this, childRealm);
+        return new BeanContainerImpl(childRealm, this);
     }
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java?rev=694163&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java Thu Sep 11 00:47:27 2008
@@ -0,0 +1,56 @@
+/*
+ * 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.spring;
+
+import junit.framework.TestCase;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.Resource;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClassPathLoadingTest
+    extends TestCase
+{
+    public void testLoad() throws Exception {
+        ClassLoader cl = getClass().getClassLoader();
+
+        GenericApplicationContext ctx = new GenericApplicationContext();
+        ctx.setClassLoader(cl);
+
+        DefaultListableBeanFactory beanFactory = ctx.getDefaultListableBeanFactory();
+
+        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
+
+        Resource[] resources = ctx.getResources("classpath*:META-INF/spring/components.xml");
+
+        for (Resource resource : resources) {
+            System.out.println(resource);
+        }
+
+        xmlReader.loadBeanDefinitions(resources);
+        
+        ctx.refresh();
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/ClassPathLoadingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml?rev=694163&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml Thu Sep 11 00:47:27 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
+    <context:annotation-config/>
+
+</beans>
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/resources/META-INF/spring/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java?rev=694163&r1=694162&r2=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java Thu Sep 11 00:47:27 2008
@@ -20,6 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.shell;
 
 import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.commandline.CommandLine;
 import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
 import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
@@ -27,22 +28,18 @@
 import org.apache.geronimo.gshell.parser.ASTCommandLine;
 import org.apache.geronimo.gshell.parser.CommandLineParser;
 import org.apache.geronimo.gshell.parser.ParseException;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.spring.BeanContainer;
+import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.application.event.ApplicationConfiguredEvent;
 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.ApplicationListener;
 import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
 
-import javax.annotation.PostConstruct;
 import java.io.Reader;
 import java.io.StringReader;
-import java.io.File;
-import java.io.IOException;
 
 /**
  * Builds {@link CommandLine} instances ready for executing.
@@ -50,38 +47,41 @@
  * @version $Rev$ $Date$
  */
 public class CommandLineBuilderImpl
-    implements CommandLineBuilder, BeanContainerAware
+    implements CommandLineBuilder //, BeanContainerAware, ApplicationListener
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
     private ApplicationManager applicationManager;
 
-    private BeanContainer container;
-
+    @Autowired
     private CommandLineExecutor executor;
 
+    // private BeanContainer container;
+
     private final CommandLineParser parser = new CommandLineParser();
 
     public CommandLineBuilderImpl() {}
 
+    /*
     public void setBeanContainer(final BeanContainer container) {
         assert container != null;
 
         this.container = container;
     }
 
-    @PostConstruct
-    public void init() {
-        container.addListener(new ApplicationListener()
-        {
-            public void onApplicationEvent(final ApplicationEvent event) {
-                if (event instanceof ApplicationConfiguredEvent) {
-                    executor = container.getBean(CommandLineExecutor.class);
-                }
-            }
-        });
+    //
+    // TODO: See if we can @Autowire this puppy, since it looks like spring can handle the cirtcular reference?
+    //
+    
+    public void onApplicationEvent(final ApplicationEvent event) {
+        log.debug("Processing application event: {}", event);
+        
+        if (event instanceof ApplicationConfiguredEvent) {
+            executor = container.getBean(CommandLineExecutor.class);
+        }
     }
+    */
 
     private ASTCommandLine parse(final String input) throws ParseException {
         assert input != null;

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java?rev=694163&r1=694162&r2=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/HistoryImpl.java Thu Sep 11 00:47:27 2008
@@ -20,19 +20,16 @@
 package org.apache.geronimo.gshell.wisdom.shell;
 
 import jline.History;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.gshell.application.ApplicationManager;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.wisdom.application.event.ApplicationConfiguredEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
 import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
 
-import javax.annotation.PostConstruct;
-import java.io.IOException;
 import java.io.File;
+import java.io.IOException;
 
 /**
  * Default implementation of the {@link jline.History} component.
@@ -41,47 +38,34 @@
  */
 public class HistoryImpl
     extends History
-    implements BeanContainerAware
+    implements ApplicationListener
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private BeanContainer container;
-
     @Autowired
     private ApplicationManager applicationManager;
 
     public HistoryImpl() {}
 
-    public void setBeanContainer(BeanContainer container) {
-        assert container != null;
-        this.container = container;
-    }
+    public void onApplicationEvent(final ApplicationEvent event) {
+        log.debug("Processing application event: {}", event);
+
+        if (event instanceof ApplicationConfiguredEvent) {
+            assert applicationManager != null;
+
+            try {
+                File file = applicationManager.getContext().getApplication().getBranding().getHistoryFile();
 
-    @PostConstruct
-    public void init() {
-        container.addListener(new ApplicationListener()
-        {
-            public void onApplicationEvent(final ApplicationEvent event) {
-                log.debug("Processing application event: {}", event);
-                
-                if (event instanceof ApplicationConfiguredEvent) {
-                    assert applicationManager != null;
-
-                    try {
-                        File file = applicationManager.getContext().getApplication().getBranding().getHistoryFile();
-
-                        log.debug("Application configured, setting history file: {}", file);
-
-                        setHistoryFile(file);
-                    }
-                    catch (IOException e) {
-                        throw new RuntimeException("Failed to set history file", e);
-                    }
-                }
+                log.debug("Application configured, setting history file: {}", 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;
 

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=694163&r1=694162&r2=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java Thu Sep 11 00:47:27 2008
@@ -21,8 +21,8 @@
 
 import jline.History;
 import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.application.ApplicationContext;
+import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
 import org.apache.geronimo.gshell.console.Console;
@@ -36,20 +36,16 @@
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.shell.ShellInfo;
 import org.apache.geronimo.gshell.wisdom.application.event.ApplicationConfiguredEvent;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.spring.BeanContainer;
 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.ApplicationListener;
 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;
-import java.io.IOException;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -58,7 +54,7 @@
  * @version $Rev$ $Date$
  */
 public class ShellImpl
-    implements Shell, BeanContainerAware
+    implements Shell, ApplicationListener
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -74,8 +70,6 @@
     @Autowired
     private History history;
 
-    private BeanContainer container;
-
     private Variables variables;
 
     private IO io;
@@ -100,37 +94,26 @@
         return true;
     }
 
-    public void setBeanContainer(BeanContainer container) {
-        assert container != null;
 
-        this.container = container;
-    }
+    public void onApplicationEvent(final ApplicationEvent event) {
+        log.debug("Processing application event: {}", event);
 
-    @PostConstruct
-    public void init() {
-        container.addListener(new ApplicationListener()
-        {
-            public void onApplicationEvent(final ApplicationEvent event) {
-                log.debug("Processing application event: {}", event);
-
-                if (event instanceof ApplicationConfiguredEvent) {
-                    assert applicationManager != null;
-
-                    // Dereference some bits from the applciation context
-                    ApplicationContext context = applicationManager.getContext();
-                    io = context.getIo();
-                    variables = context.getVariables();
-                    branding = context.getApplication().getBranding();
-
-                    try {
-                        loadProfileScripts();
-                    }
-                    catch (Exception e) {
-                        throw new RuntimeException(e.getMessage(), e);
-                    }
-                }
+        if (event instanceof ApplicationConfiguredEvent) {
+            assert applicationManager != null;
+
+            // Dereference some bits from the applciation context
+            ApplicationContext context = applicationManager.getContext();
+            io = context.getIo();
+            variables = context.getVariables();
+            branding = context.getApplication().getBranding();
+
+            try {
+                loadProfileScripts();
             }
-        });
+            catch (Exception e) {
+                throw new RuntimeException(e.getMessage(), e);
+            }
+        }
     }
     
     //

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/VariableInterpolator.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/VariableInterpolator.java?rev=694163&r1=694162&r2=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/VariableInterpolator.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/VariableInterpolator.java Thu Sep 11 00:47:27 2008
@@ -37,6 +37,10 @@
 import java.util.Set;
 import java.util.List;
 
+//
+// TODO: Move to gshell-interpolation
+//
+
 /**
  * Provides interpolation for shell variables using Jexl.
  *

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/resources/META-INF/spring/components.xml?rev=694163&r1=694162&r2=694163&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/resources/META-INF/spring/components.xml Thu Sep 11 00:47:27 2008
@@ -33,38 +33,30 @@
     
     <!-- Application -->
 
-    <bean id="applicationManager" class="org.apache.geronimo.gshell.wisdom.application.ApplicationManagerImpl">
-    </bean>
+    <bean id="applicationManager" class="org.apache.geronimo.gshell.wisdom.application.ApplicationManagerImpl"/>
 
-    <bean id="settingsManager" class="org.apache.geronimo.gshell.wisdom.application.SettingsManagerImpl">
-    </bean>
+    <bean id="settingsManager" class="org.apache.geronimo.gshell.wisdom.application.SettingsManagerImpl"/>
     
     <!-- Command -->
 
-    <bean id="commandContainerFactory" class="org.apache.geronimo.gshell.wisdom.command.CommandContainerFactoryImpl">
-    </bean>
+    <bean id="commandContainerFactory" class="org.apache.geronimo.gshell.wisdom.command.CommandContainerFactoryImpl"/>
 
-    <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.command.CommandResolverImpl">
-    </bean>
+    <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.command.CommandResolverImpl"/>
 
     <!-- Shell -->
 
-    <bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl">
-    </bean>
+    <bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl"/>
 
-    <bean id="commandLineExecutor" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineExecutorImpl">
-    </bean>
+    <bean id="commandLineExecutor" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineExecutorImpl"/>
 
-    <bean id="history" class="org.apache.geronimo.gshell.wisdom.shell.HistoryImpl">
-    </bean>
+    <bean id="history" class="org.apache.geronimo.gshell.wisdom.shell.HistoryImpl"/>
 
-    <bean id="layoutManager" class="org.apache.geronimo.gshell.wisdom.shell.LayoutManagerImpl">
-    </bean>
+    <bean id="layoutManager" class="org.apache.geronimo.gshell.wisdom.shell.LayoutManagerImpl"/>
 
-    <bean id="shell" class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl">
-    </bean>
+    <bean id="shellInfo" class="org.apache.geronimo.gshell.wisdom.shell.ShellInfoImpl"/>
+
+    <!--
+    <bean id="shell" class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl" lazy-init="true"/>
+    -->
 
-    <bean id="shellInfo" class="org.apache.geronimo.gshell.wisdom.shell.ShellInfoImpl">
-    </bean>
-    
 </beans>
\ No newline at end of file