geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r694138 - in /geronimo/gshell/trunk: ./ gshell-assembly/src/main/underlay/etc/ gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/ gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ gshell-wisdom/src/...
Date Thu, 11 Sep 2008 05:27:59 GMT
Author: jdillon
Date: Wed Sep 10 22:27:58 2008
New Revision: 694138

URL: http://svn.apache.org/viewvc?rev=694138&view=rev
Log:
Use events to configure components which require a configured application

Added:
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
  (with props)
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/commands.xml
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.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/CommandLineExecutorImpl.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/pom.xml

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Wed Sep 10
22:27:58 2008
@@ -46,11 +46,11 @@
 
     <dependencyGroups>
         <dependencyGroup>
-            <groupId>org.apache.geronimo.gshell.rapture</groupId>
+            <groupId>org.apache.geronimo.gshell</groupId>
             <version>1.0-alpha-2-SNAPSHOT</version>
 
             <dependency>
-                <artifactId>gshell-rapture-core</artifactId>
+                <artifactId>gshell-wisdom</artifactId>
             </dependency>
         </dependencyGroup>
 
@@ -62,6 +62,7 @@
                 <artifactId>gshell-builtins</artifactId>
             </dependency>
 
+            <!--
             <dependency>
                 <artifactId>gshell-optional</artifactId>
             </dependency>
@@ -77,8 +78,10 @@
             <dependency>
                 <artifactId>gshell-vfs</artifactId>
             </dependency>
+            -->
         </dependencyGroup>
 
+        <!--
         <dependencyGroup>
             <groupId>org.apache.geronimo.gshell.remote</groupId>
             <version>1.0-alpha-2-SNAPSHOT</version>
@@ -91,6 +94,7 @@
                 <artifactId>gshell-remote-server</artifactId>
             </dependency>
         </dependencyGroup>
+        -->
     </dependencyGroups>
 
     <!--

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties Wed Sep
10 22:27:58 2008
@@ -58,4 +58,7 @@
 # Keep some of the bits used to handle artifacts + repository muck quieter
 log4j.logger.org.apache.maven=INFO
 log4j.logger.org.apache.maven.artifact.manager=ERROR
-log4j.logger.org.apache.maven.artifact.repository.metadata=WARN
\ No newline at end of file
+log4j.logger.org.apache.maven.artifact.repository.metadata=WARN
+
+# Make spring be terse
+log4j.logger.org.springframework=INFO
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/commands.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/commands.xml?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/commands.xml
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/gshell/commands.xml
Wed Sep 10 22:27:58 2008
@@ -46,8 +46,10 @@
 
         <property name="documenter">
             <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl">
+                <!--
                 <property name="name" value="echo"/>
                 <property name="description" value="Blah, blah, blah"/>
+                -->
             </bean>
         </property>
     </bean>

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
Wed Sep 10 22:27:58 2008
@@ -35,6 +35,9 @@
 import org.apache.geronimo.gshell.model.interpolate.InterpolatorSupport;
 import org.apache.geronimo.gshell.model.settings.Settings;
 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.event.ApplicationConfiguredEvent;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -63,7 +66,7 @@
  * @version $Rev$ $Date$
  */
 public class ApplicationManagerImpl
-    implements ApplicationManager
+    implements ApplicationManager, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -75,6 +78,16 @@
 
     private ApplicationContext applicationContext;
 
+    private BeanContainer container;
+
+    private BeanContainer applicationContainer;
+
+    public void setBeanContainer(final BeanContainer container) {
+        assert container != null;
+        
+        this.container = container;
+    }
+
     public ApplicationContext getContext() {
         if (applicationContext == null) {
             throw new IllegalStateException("Application has not been configured");
@@ -111,6 +124,10 @@
                 return config.getApplication();
             }
         };
+
+        log.debug("Application configured");
+        
+        applicationContainer.publish(new ApplicationConfiguredEvent(this));
     }
 
     private void interpolate(final ApplicationConfiguration config) throws Exception {
@@ -148,8 +165,7 @@
         configureArtifactManager(application);
 
         // Create the application container
-        // FIXME:
-        // container = createContainer(application);
+        applicationContainer = createContainer(application);
     }
 
     private void configureArtifactManager(final Application application) throws Exception
{
@@ -169,36 +185,19 @@
         }
     }
 
-    /*
-    private GShellPlexusContainer createContainer(final Application application) throws Exception
{
+    private BeanContainer createContainer(final Application application) throws Exception
{
         assert application != null;
 
         log.debug("Creating application container");
 
         List<URL> classPath = createClassPath(application);
 
-        ClassWorld world = new ClassWorld();
-        ClassRealm realm = world.newRealm("gshell.application[" + application.getId().replace(".",
"/") + "]");
-        realm.setParentRealm(parentContainer.getContainerRealm());
-
-        for (URL url : classPath) {
-            realm.addURL(url);
-        }
-
-        ContainerConfiguration config = new DefaultContainerConfiguration();
-        config.setName(application.getId());
-        config.setClassWorld(world);
-        config.setRealm(realm);
-        config.addComponentDiscoverer(new PluginDiscoverer());
-        config.addComponentDiscoveryListener(new PluginCollector());
-
-        GShellPlexusContainer child = parentContainer.createChild(config);
+        BeanContainer child = container.createChild(application.getId(), classPath);
 
         log.debug("Application container: {}", child);
 
         return child;
     }
-    */
 
     private List<URL> createClassPath(final Application application) throws Exception
{
         assert application != null;
@@ -246,8 +245,10 @@
             "gshell-i18n",
             "gshell-io",
             "gshell-model",
-            "gshell-plexus",
-            "gshell-rapture-bootstrap",
+            // "gshell-plexus",
+            // "gshell-rapture-bootstrap",
+            "gshell-spring",
+            "gshell-wisdom",
             "gshell-yarn",
             "jcl104-over-slf4j",
             "jline",
@@ -271,6 +272,11 @@
             "xbean-reflect",
             "xpp3_min",
             "xstream-",
+            "geronimo-annotation_1.0_spec",
+            "spring-core",
+            "spring-context",
+            "spring-beans",
+            "aopalliance",
         });
 
         if (resolvedArtifacts != null && !resolvedArtifacts.isEmpty()) {
@@ -296,7 +302,7 @@
         // Make sure that we have a valid context
         getContext();
 
-        final Shell shell = null; // FIXME: container.lookupComponent(Shell.class);
+        final Shell shell = applicationContainer.getBean(Shell.class);
 
         log.debug("Created shell instance: {}", shell);
 

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/SettingsManagerImpl.java
Wed Sep 10 22:27:58 2008
@@ -26,6 +26,9 @@
 import org.apache.geronimo.gshell.model.interpolate.Interpolator;
 import org.apache.geronimo.gshell.model.interpolate.InterpolatorSupport;
 import org.apache.geronimo.gshell.model.settings.Settings;
+import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.geronimo.gshell.spring.BeanContainer;
+import org.apache.geronimo.gshell.wisdom.application.event.SettingsConfiguredEvent;
 import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,7 +40,7 @@
  * @version $Rev$ $Date$
  */
 public class SettingsManagerImpl
-    implements SettingsManager
+    implements SettingsManager, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -46,6 +49,14 @@
 
     private SettingsConfiguration settingsConfiguration;
 
+    private BeanContainer container;
+
+    public void setBeanContainer(final BeanContainer container) {
+        assert container != null;
+
+        this.container = container;
+    }
+
     public Settings getSettings() {
         if (settingsConfiguration == null) {
             throw new IllegalStateException("Not configured");
@@ -73,6 +84,10 @@
         // TODO: Merge in some default settings or something?
 
         settingsConfiguration = config;
+
+        log.debug("Settings configured");
+
+        container.publish(new SettingsConfiguredEvent(this));
     }
 
     private void interpolate(final SettingsConfiguration config) throws Exception {

Added: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java?rev=694138&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
Wed Sep 10 22:27:58 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.application.event;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class ApplicationConfiguredEvent
+    extends ApplicationEvent
+{
+    public ApplicationConfiguredEvent(Object source) {
+        super(source);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/ApplicationConfiguredEvent.java
------------------------------------------------------------------------------
    svn:executable = *

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

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

Added: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java?rev=694138&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
Wed Sep 10 22:27:58 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.wisdom.application.event;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class SettingsConfiguredEvent
+    extends ApplicationEvent
+{
+    public SettingsConfiguredEvent(Object source) {
+        super(source);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/application/event/SettingsConfiguredEvent.java
------------------------------------------------------------------------------
    svn:executable = *

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

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

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=694138&r1=694137&r2=694138&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
Wed Sep 10 22:27:58 2008
@@ -28,13 +28,21 @@
 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.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 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.
@@ -42,20 +50,39 @@
  * @version $Rev$ $Date$
  */
 public class CommandLineBuilderImpl
-    implements CommandLineBuilder
+    implements CommandLineBuilder, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
     private ApplicationManager applicationManager;
 
-    @Autowired
+    private BeanContainer container;
+
     private CommandLineExecutor executor;
 
     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);
+                }
+            }
+        });
+    }
+
     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/CommandLineExecutorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
Wed Sep 10 22:27:58 2008
@@ -41,8 +41,6 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import javax.annotation.Resource;
-import javax.annotation.PostConstruct;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
@@ -71,20 +69,6 @@
     @Autowired
     private CommandLineBuilder commandLineBuilder;
 
-    private Variables variables;
-
-    private IO io;
-
-    public CommandLineExecutorImpl() {}
-
-    @PostConstruct
-    public void init() {
-        assert applicationManager != null;
-
-        this.variables = applicationManager.getContext().getVariables();
-        this.io = applicationManager.getContext().getIo();
-    }
-
     public Object execute(final String line) throws Exception {
         assert line != null;
 
@@ -118,7 +102,7 @@
 
         log.info("Executing (Object...): [{}]", Arguments.asString(args));
 
-        return execute(String.valueOf(args[0]), Arguments.shift(args), io);
+        return execute(String.valueOf(args[0]), Arguments.shift(args), applicationManager.getContext().getIo());
     }
 
     public Object execute(final String path, final Object[] args) throws Exception {
@@ -127,7 +111,7 @@
 
         log.info("Executing ({}): [{}]", path, Arguments.asString(args));
 
-        return execute(path, args, io);
+        return execute(path, args, applicationManager.getContext().getIo());
     }
 
     public Object execute(final Object[][] commands) throws Exception {
@@ -137,6 +121,8 @@
         final IO[] ios = new IO[commands.length];
         PipedOutputStream pos = null;
 
+        IO io = applicationManager.getContext().getIo();
+
         for (int i = 0; i < ios.length; i++) {
             InputStream is = (i == 0) ? io.inputStream : new PipedInputStream(pos);
             OutputStream os;
@@ -214,6 +200,8 @@
     protected Object execute(final String path, final Object[] args, final IO io) throws
Exception {
         log.debug("Executing");
 
+        final Variables variables = applicationManager.getContext().getVariables();
+
         final Command command = commandResolver.resolve(variables, path);
 
         // Setup the command context and pass it to the command instance

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=694138&r1=694137&r2=694138&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
Wed Sep 10 22:27:58 2008
@@ -23,7 +23,12 @@
 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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.ApplicationEvent;
 
 import javax.annotation.PostConstruct;
 import java.io.IOException;
@@ -36,26 +41,47 @@
  */
 public class HistoryImpl
     extends History
+    implements BeanContainerAware
 {
     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;
+    }
+
     @PostConstruct
     public void init() {
-        assert applicationManager != null;
-
-        try {
-            setHistoryFile(applicationManager.getContext().getApplication().getBranding().getHistoryFile());
-        }
-        catch (IOException e) {
-            throw new RuntimeException("Failed to set history file", e);
-        }
+        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);
+                    }
+                }
+            }
+        });
     }
-
+    
     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=694138&r1=694137&r2=694138&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
Wed Sep 10 22:27:58 2008
@@ -35,15 +35,21 @@
 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.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 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;
 
 /**
@@ -52,7 +58,7 @@
  * @version $Rev$ $Date$
  */
 public class ShellImpl
-    implements Shell
+    implements Shell, BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -68,6 +74,8 @@
     @Autowired
     private History history;
 
+    private BeanContainer container;
+
     private Variables variables;
 
     private IO io;
@@ -92,24 +100,39 @@
         return true;
     }
 
-    @PostConstruct
-    public void init() {
-        assert applicationManager != null;
-
-        // Dereference some bits from the applciation context
-        ApplicationContext context = applicationManager.getContext();
-        this.io = context.getIo();
-        this.variables = context.getVariables();
-        this.branding = context.getApplication().getBranding();
+    public void setBeanContainer(BeanContainer container) {
+        assert container != null;
 
-        try {
-            loadProfileScripts();
-        }
-        catch (Exception e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
+        this.container = container;
     }
 
+    @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);
+                    }
+                }
+            }
+        });
+    }
+    
     //
     // Command Execution (all delegates)
     //
@@ -139,6 +162,7 @@
 
         log.debug("Starting interactive console; args: {}", args);
 
+
         assert branding != null;
         loadUserScript(branding.getInteractiveScriptName());
 

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=694138&r1=694137&r2=694138&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Wed Sep 10 22:27:58 2008
@@ -165,6 +165,16 @@
                 <groupId>org.apache.maven</groupId>
                 <artifactId>maven-project</artifactId>
                 <version>2.1.0-SNAPSHOT</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.maven</groupId>
+                        <artifactId>maven-artifact</artifactId>
+                    </exclusion>
+                    <exclusion>
+                        <groupId>org.apache.maven</groupId>
+                        <artifactId>maven-artifact-manager</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
 
             <dependency>



Mime
View raw message