geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r697348 - in /geronimo/gshell/trunk: ./ gshell-assembly/src/main/underlay/etc/ gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/ gshell-remote/gshell-remote-server/src/main/resources/META-INF...
Date Sat, 20 Sep 2008 10:42:32 GMT
Author: jdillon
Date: Sat Sep 20 03:42:31 2008
New Revision: 697348

URL: http://svn.apache.org/viewvc?rev=697348&view=rev
Log:
Added BeanContainerSupport to support testing
Refactored to use shared SpringTestSupport
Added more BeanContainer related logging
Changed bootstrap classworlds to use the "gshell.bootstrap" realm
Have to use a named "remoteShell" bean to propertly lookup a RemoteShell instance

Added:
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerSupport.java
  (contents, props changed)
      - copied, changed from r697337, geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java
Removed:
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/SpringTestSupport.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/SpringTestSupport.java
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-classworlds.conf
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
    geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/pom.xml
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTest.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/pom.xml
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java
    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/BeanContainerImpl.java
    geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/SpringTestSupport.java
    geronimo/gshell/trunk/pom.xml

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-classworlds.conf
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-classworlds.conf?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-classworlds.conf (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-classworlds.conf Sat Sep
20 03:42:31 2008
@@ -25,9 +25,9 @@
 ## FIXME: Drop this file, or hide it as a resource
 ##
 
-main is org.apache.geronimo.gshell.cli.Main from gshell
+main is org.apache.geronimo.gshell.cli.Main from gshell.bootstrap
 
-[gshell]
+[gshell.bootstrap]
     load ${gshell.home}/etc
     load ${gshell.home}/lib/*.jar
 

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/handler/OpenShellHandler.java
Sat Sep 20 03:42:31 2008
@@ -65,7 +65,7 @@
         // context.variables =
         
         // Create a new shell instance
-        context.shell = context.container.getBean(RemoteShell.class);
+        context.shell = context.container.getBean("remoteShell", RemoteShell.class);
 
         //
         // TODO: Send a meaningful response

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml
Sat Sep 20 03:42:31 2008
@@ -72,6 +72,6 @@
         </constructor-arg>
     </bean>
 
-    <bean class="org.apache.geronimo.gshell.remote.server.RemoteShellImpl" scope="prototype"/>
+    <bean id="remoteShell" class="org.apache.geronimo.gshell.remote.server.RemoteShellImpl"
scope="prototype"/>
 
 </beans>
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/pom.xml?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/pom.xml Sat Sep 20 03:42:31 2008
@@ -89,6 +89,13 @@
             <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-spring</artifactId>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTest.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTest.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/message/PingPongProtocolTest.java
Sat Sep 20 03:42:31 2008
@@ -27,7 +27,7 @@
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
 import org.apache.geronimo.gshell.whisper.transport.TransportServer;
-import org.apache.geronimo.gshell.whisper.SpringTestSupport;
+import org.apache.geronimo.gshell.spring.SpringTestSupport;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.DemuxingIoHandler;
 import org.apache.mina.handler.demux.MessageHandler;

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocatorTest.java
Sat Sep 20 03:42:31 2008
@@ -24,7 +24,7 @@
 import org.apache.geronimo.gshell.whisper.transport.ssl.SslTransportFactory;
 import org.apache.geronimo.gshell.whisper.transport.tcp.TcpTransportFactory;
 import org.apache.geronimo.gshell.whisper.transport.vm.VmTransportFactory;
-import org.apache.geronimo.gshell.whisper.SpringTestSupport;
+import org.apache.geronimo.gshell.spring.SpringTestSupport;
 
 /**
  * Tests for the {@link TransportFactoryLocator} class.

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactoryTest.java
Sat Sep 20 03:42:31 2008
@@ -24,7 +24,7 @@
 import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
 import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
 import org.apache.geronimo.gshell.whisper.transport.TransportServer;
-import org.apache.geronimo.gshell.whisper.SpringTestSupport;
+import org.apache.geronimo.gshell.spring.SpringTestSupport;
 import org.apache.mina.common.IoHandlerAdapter;
 
 /**

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/pom.xml?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/pom.xml Sat Sep 20 03:42:31 2008
@@ -84,6 +84,13 @@
             <artifactId>spring-test</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-spring</artifactId>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java
Sat Sep 20 03:42:31 2008
@@ -19,6 +19,8 @@
 
 package org.apache.geronimo.gshell.artifact;
 
+import org.apache.geronimo.gshell.spring.SpringTestSupport;
+
 /**
  * Unit tests for the {@link ArtifactManagerFactory} class.
  *

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=697348&r1=697347&r2=697348&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
Sat Sep 20 03:42:31 2008
@@ -57,5 +57,5 @@
 
     BeanContainer createChild(String id);
 
-    // TODO: Add wire(Object obj)
+    // Object configure(Object bean);
 }

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=697348&r1=697347&r2=697348&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
Sat Sep 20 03:42:31 2008
@@ -22,15 +22,11 @@
 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.FatalBeanException;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ConfigurableApplicationContext;
 
 import java.net.URL;
-import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Default {@link BeanContainer} implementation.
@@ -38,12 +34,10 @@
  * @version $Rev$ $Date$
  */
 public class BeanContainerImpl
-    implements BeanContainer
+    extends BeanContainerSupport
 {
     private static final String REALM_ID = "gshell";
 
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
     private BeanContainer parent;
 
     private BeanContainerContext context;
@@ -91,6 +85,10 @@
         context.refresh();
     }
 
+    protected ConfigurableApplicationContext getContext() {
+        return context;
+    }
+
     public BeanContainer getParent() {
         return parent;
     }
@@ -99,69 +97,19 @@
         return classRealm;
     }
 
-    public void start() {
-        log.debug("Starting");
-
-        context.start();
-    }
-
-    public void stop() {
-        log.debug("Stopping");
-
-        context.stop();
-    }
-
-    public void close() {
-        log.debug("Closing");
-        
-        context.close();
-    }
-
-    public <T> T getBean(final Class<T> type) {
-        assert type != null;
-
-        String[] names = context.getBeanNamesForType(type);
-
-        if (names.length == 0) {
-            throw new NoSuchBeanDefinitionException(type, "No bean defined for type: " +
type);
-        }
-        if (names.length > 1) {
-            throw new NoSuchBeanDefinitionException(type, "No unique bean defined for type:
" + type + ", found matches: " + Arrays.asList(names));
-        }
-
-        return getBean(names[0], type);
-    }
-
-    @SuppressWarnings({"unchecked"})
-    public <T> T getBean(final String name, final Class<T> requiredType) {
-        assert name != null;
-        assert requiredType != null;
-
-        return (T) context.getBean(name, requiredType);
-    }
-
-    @SuppressWarnings({"unchecked"})
-    public <T> Map<String,T> getBeans(final Class<T> type) {
-        assert type != null;
-
-        return (Map<String,T>)context.getBeansOfType(type);
-    }
-
-    public String[] getBeanNames() {
-        return context.getBeanDefinitionNames();
-    }
-
-    public String[] getBeanNames(final Class type) {
-        assert type != null;
-
-        return context.getBeanNamesForType(type);
-    }
-
     public BeanContainer createChild(final String id, final List<URL> classPath) {
         assert id != null;
         // classPath may be null
 
-        log.debug("Creating child container: {}", id);
+        if (log.isTraceEnabled()) {
+            log.trace("Creating child container: {}", id);
+            if (classPath != null) {
+                log.trace("Classpath:");
+                for (URL url : classPath) {
+                    log.trace("    {}", url);
+                }
+            }
+        }
 
         ClassRealm childRealm;
         try {
@@ -180,9 +128,13 @@
         return new BeanContainerImpl(childRealm, this);
     }
 
-    public BeanContainer createChild(final String id) {
-        assert id != null;
+    /*
+    public Object configure(final Object bean) {
+        assert bean != null;
+
+        context.getAutowireCapableBeanFactory().autowireBean(bean);
 
-        return createChild(id, null);
+        return bean;
     }
+    */
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerSupport.java
(from r697337, 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/BeanContainerSupport.java?p2=geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerSupport.java&p1=geronimo/gshell/trunk/gshell-support/gshell-spring/src/main/java/org/apache/geronimo/gshell/spring/BeanContainerImpl.java&r1=697337&r2=697348&rev=697348&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/BeanContainerSupport.java
Sat Sep 20 03:42:31 2008
@@ -19,108 +19,50 @@
 
 package org.apache.geronimo.gshell.spring;
 
-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.FatalBeanException;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ConfigurableApplicationContext;
 
-import java.net.URL;
 import java.util.Arrays;
-import java.util.List;
 import java.util.Map;
 
 /**
- * Default {@link BeanContainer} implementation.
+ * Support for {@link BeanContainer} implementations.
  *
  * @version $Rev$ $Date$
  */
-public class BeanContainerImpl
+public abstract class BeanContainerSupport
     implements BeanContainer
 {
-    private static final String REALM_ID = "gshell";
+    protected final Logger log = LoggerFactory.getLogger(getClass());
 
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    private BeanContainer parent;
-
-    private BeanContainerContext context;
-
-    private ClassRealm classRealm;
-    
-    public BeanContainerImpl(final ClassLoader classLoader) {
-        assert classLoader != null;
-
-        ClassRealm realm;
-        try {
-            realm = new ClassWorld().newRealm(REALM_ID, classLoader);
-        }
-        catch (DuplicateRealmException e) {
-            // Should never happen
-            throw new Error(e);
-        }
-
-        configureContext(realm, null);
-    }
-
-    /**
-     * 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.classRealm = classRealm;
-
-        // Construct the container and add customizations
-        context = new BeanContainerContext(classRealm, parent != null ? parent.context :
null);
-        context.registerShutdownHook();
-        context.addBeanPostProcessor(new BeanContainerAwareProcessor(this));
-
-        // Refresh to load things up
-        context.refresh();
-    }
-
-    public BeanContainer getParent() {
-        return parent;
-    }
-
-    public ClassRealm getClassRealm() {
-        return classRealm;
-    }
+    protected abstract ConfigurableApplicationContext getContext();
 
     public void start() {
-        log.debug("Starting");
+        log.trace("Starting");
 
-        context.start();
+        getContext().start();
     }
 
     public void stop() {
-        log.debug("Stopping");
+        log.trace("Stopping");
 
-        context.stop();
+        getContext().stop();
     }
 
     public void close() {
-        log.debug("Closing");
-        
-        context.close();
+        log.trace("Closing");
+
+        getContext().close();
     }
 
     public <T> T getBean(final Class<T> type) {
         assert type != null;
 
-        String[] names = context.getBeanNamesForType(type);
+        log.trace("Getting bean of type: {}", type);
+
+        String[] names = getContext().getBeanNamesForType(type);
 
         if (names.length == 0) {
             throw new NoSuchBeanDefinitionException(type, "No bean defined for type: " +
type);
@@ -137,47 +79,32 @@
         assert name != null;
         assert requiredType != null;
 
-        return (T) context.getBean(name, requiredType);
+        log.trace("Getting bean named '{}' of type: {}", name, requiredType);
+
+        return (T) getContext().getBean(name, requiredType);
     }
 
     @SuppressWarnings({"unchecked"})
     public <T> Map<String,T> getBeans(final Class<T> type) {
         assert type != null;
 
-        return (Map<String,T>)context.getBeansOfType(type);
+        log.trace("Getting beans of type: {}", type);
+
+        return (Map<String,T>)getContext().getBeansOfType(type);
     }
 
     public String[] getBeanNames() {
-        return context.getBeanDefinitionNames();
+        log.trace("Getting bean names");
+
+        return getContext().getBeanDefinitionNames();
     }
 
     public String[] getBeanNames(final Class type) {
         assert type != null;
 
-        return context.getBeanNamesForType(type);
-    }
-
-    public BeanContainer createChild(final String id, final List<URL> classPath) {
-        assert id != null;
-        // classPath may be null
-
-        log.debug("Creating child container: {}", id);
-
-        ClassRealm childRealm;
-        try {
-            childRealm = classRealm.createChildRealm(id);
-        }
-        catch (DuplicateRealmException e) {
-            throw new FatalBeanException("Failed to create child container realm: " + id,
e);
-        }
-
-        if (classPath != null) {
-            for (URL url : classPath) {
-                childRealm.addURL(url);
-            }
-        }
+        log.trace("Getting bean names of type: {}", type);
 
-        return new BeanContainerImpl(childRealm, this);
+        return getContext().getBeanNamesForType(type);
     }
 
     public BeanContainer createChild(final String id) {

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

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

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

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

Modified: geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/SpringTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/SpringTestSupport.java?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/SpringTestSupport.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-spring/src/test/java/org/apache/geronimo/gshell/spring/SpringTestSupport.java
Sat Sep 20 03:42:31 2008
@@ -20,6 +20,16 @@
 package org.apache.geronimo.gshell.spring;
 
 import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+
+import java.util.Map;
+import java.util.List;
+import java.net.URL;
 
 /**
  * Suport for Spring-based tests.
@@ -29,9 +39,46 @@
 public abstract class SpringTestSupport
     extends AbstractDependencyInjectionSpringContextTests
 {
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
     protected String[] getConfigLocations() {
         return new String[] {
             "classpath:" + getClass().getName().replace('.', '/') + "-context.xml"
         };
     }
+
+    private BeanContainer container;
+
+    protected void prepareApplicationContext(final GenericApplicationContext context) {
+        assert context != null;
+
+	    log.debug("Prepare applciation context");
+
+        container = new BeanContainerSupport() {
+            protected ConfigurableApplicationContext getContext() {
+                return context;
+            }
+
+            public BeanContainer getParent() {
+                return null;
+            }
+
+            public ClassRealm getClassRealm() {
+                throw new UnsupportedOperationException();
+            }
+
+            public BeanContainer createChild(final String id, final List<URL> classPath)
{
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+
+    protected void customizeBeanFactory(final DefaultListableBeanFactory beanFactory) {
+        assert beanFactory != null;
+
+        log.debug("Customize bean factory");
+
+        assert container != null;
+        beanFactory.addBeanPostProcessor(new BeanContainerAwareProcessor(container));
+	}
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=697348&r1=697347&r2=697348&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Sat Sep 20 03:42:31 2008
@@ -462,6 +462,13 @@
 
             <dependency>
                 <groupId>org.apache.geronimo.gshell.support</groupId>
+                <artifactId>gshell-spring</artifactId>
+                <classifier>tests</classifier>
+                <version>1.0-alpha-2-SNAPSHOT</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.geronimo.gshell.support</groupId>
                 <artifactId>gshell-artifact</artifactId>
                 <version>1.0-alpha-2-SNAPSHOT</version>
             </dependency>



Mime
View raw message