geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r706676 - in /geronimo/gshell/trunk: gshell-assembly/src/main/underlay/etc/ gshell-bootstrap/ gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ gshell-wisdom/gshell-wisdom-bootstrap/src/main/...
Date Tue, 21 Oct 2008 16:20:30 GMT
Author: jdillon
Date: Tue Oct 21 09:20:29 2008
New Revision: 706676

URL: http://svn.apache.org/viewvc?rev=706676&view=rev
Log:
Ditch using xstore for plugin classpath cache, use java ser just like appman, Created ClassPathCache
to use the same code
Don't require Ivy to boot, load the component only when its needed
Turn off all but builtins for perf testing comparisons with alpha-1

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java
  (contents, props changed)
      - copied, changed from r706624, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-bootstrap/pom.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/resources/META-INF/spring/components.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.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=706676&r1=706675&r2=706676&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 Tue Oct 21
09:20:29 2008
@@ -63,6 +63,7 @@
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
+                <!--
                 <bean class="org.apache.geronimo.gshell.application.model.Artifact">
                     <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
                     <property name="artifactId" value="gshell-vfs"/>
@@ -75,7 +76,6 @@
                     <property name="version" value="1.0-alpha-2-SNAPSHOT"/>
                 </bean>
 
-                <!--
                 <bean class="org.apache.geronimo.gshell.application.model.Artifact">
                     <property name="groupId" value="org.apache.geronimo.gshell.commands"/>
                     <property name="artifactId" value="gshell-optional"/>

Modified: geronimo/gshell/trunk/gshell-bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/pom.xml?rev=706676&r1=706675&r2=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-bootstrap/pom.xml Tue Oct 21 09:20:29 2008
@@ -36,6 +36,10 @@
     <description>
         Provides the tiny GShell bootstrap jar to keep platform scripts as simple as possible.
     </description>
+
+    <properties>
+        <maven.test.skip>true</maven.test.skip>
+    </properties>
     
     <build>
         <plugins>

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java?rev=706676&r1=706675&r2=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
Tue Oct 21 09:20:29 2008
@@ -29,7 +29,6 @@
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.geronimo.gshell.event.EventPublisher;
-import org.apache.geronimo.gshell.io.Closer;
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
@@ -45,13 +44,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -73,19 +66,15 @@
 
     private final EventPublisher eventPublisher;
 
-    private final Ivy ivy;
-    
     private BeanContainer container;
 
     private BeanContainer applicationContainer;
 
     private Application application;
 
-    public ApplicationManagerImpl(final EventPublisher eventPublisher, final Ivy ivy) {
+    public ApplicationManagerImpl(final EventPublisher eventPublisher) {
         assert eventPublisher != null;
         this.eventPublisher = eventPublisher;
-        assert ivy != null;
-        this.ivy = ivy;
     }
 
     public void setBeanContainer(final BeanContainer container) {
@@ -151,43 +140,14 @@
     private ClassPath loadClassPath(final ApplicationModel model) throws Exception {
         assert model != null;
 
-        // FIXME: Get state directory from application/branding
-        File file = new File(new File(System.getProperty("gshell.home")), "var/classpath.ser");
-        ClassPath classPath = null;
-
-        //
-        // HACK: Using a serialized object here, for lack of a better choice.  XStream is
not on the classpath yet, and the java.beans.XMLEncoder sucks my balls.
-        //
-
-        if (file.exists()) {
-            ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
-            try {
-                classPath = (ClassPath)input.readObject();
-                log.debug("Loaded classpath from cache: {}", file);
-            }
-            finally {
-                Closer.close(input);
-            }
-
-            if (!classPath.isValid()) {
-                classPath = null;
-                log.debug("Classpath is not valid; reloading");
-            }
-        }
+        // FIXME: Get basedir from application
+        ClassPathCache cache = new ClassPathCache(new File(new File(System.getProperty("gshell.home")),
"var/classpath.ser"));
+        ClassPath classPath = cache.get();
 
         if (classPath == null) {
             Set<Artifact> artifacts = resolveArtifacts(model);
             classPath = new ClassPathImpl(artifacts);
-            log.debug("Saving classpath to cache: {}", file);
-            // noinspection ResultOfMethodCallIgnored
-            file.getParentFile().mkdirs();
-            ObjectOutputStream output = new ObjectOutputStream(new BufferedOutputStream(new
FileOutputStream(file)));
-            try {
-                output.writeObject(classPath);
-            }
-            finally {
-                Closer.close(output);
-            }
+            cache.set(classPath);
         }
         
         if (log.isDebugEnabled()) {
@@ -217,6 +177,8 @@
 
         StopWatch watch = new StopWatch(true);
 
+        Ivy ivy = container.getBean("ivy", Ivy.class);
+        
         ResolveReport resolveReport = ivy.resolve(md, options);
 
         log.debug("Resolve completed in: {}", watch);

Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java
(from r706624, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java&r1=706624&r2=706676&rev=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java
Tue Oct 21 09:20:29 2008
@@ -20,75 +20,72 @@
 package org.apache.geronimo.gshell.wisdom.application;
 
 import org.apache.geronimo.gshell.application.ClassPath;
-import org.apache.geronimo.gshell.application.model.Artifact;
+import org.apache.geronimo.gshell.io.Closer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.ObjectOutputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
 
 /**
- * {@link ClassPath} implementation backed up by a set of artifacts.
+ * Helper to manage caching of {@link ClassPath} instances.
  *
  * @version $Rev$ $Date$
  */
-public class ClassPathImpl
-    implements ClassPath, Serializable
+public class ClassPathCache
 {
-    private static final long serialVersionUID = 1;
-    
-    private Collection<Artifact> artifacts;
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private transient Collection<URL> urls;
+    private final File file;
 
-    public ClassPathImpl() {}
+    public ClassPathCache(final File file) {
+        assert file != null;
+        this.file = file;
+    }
 
-    public ClassPathImpl(final Collection<Artifact> artifacts) {
-        assert artifacts != null;
+    public void set(final ClassPath classPath) throws IOException {
+        assert classPath != null;
 
-        this.artifacts = artifacts;
+        // noinspection ResultOfMethodCallIgnored
+        file.getParentFile().mkdirs();
+        ObjectOutputStream output = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
+        try {
+            output.writeObject(classPath);
+            log.debug("Saved classpath to cache: {}", file);
+        }
+        finally {
+            Closer.close(output);
+        }
     }
 
-    public Collection<Artifact> getArtifacts() {
-        assert artifacts != null;
-        return Collections.unmodifiableCollection(artifacts);
-    }
+    public ClassPath get() throws IOException, ClassNotFoundException {
+        if (!file.exists()) {
+            return null;
+        }
 
-    public Collection<URL> getUrls() {
-        if (urls == null) {
-            List<URL> list = new ArrayList<URL>(artifacts.size());
-
-            for (Artifact artifact : artifacts) {
-                File file = artifact.getFile();
-
-                if (file != null) {
-                    try {
-                        list.add(file.toURI().toURL());
-                    }
-                    catch (MalformedURLException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
+        ClassPath classPath;
 
-            this.urls = Collections.unmodifiableCollection(list);
+        ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
+        try {
+            classPath = (ClassPath)input.readObject();
+            log.debug("Loaded classpath from cache: {}", file);
+        }
+        finally {
+            Closer.close(input);
         }
 
-        return urls;
-    }
-
-    public boolean isValid() {
-        for (Artifact artifact : artifacts) {
-            File file = artifact.getFile();
-            if (file != null && !file.exists()) {
-                return false;
-            }
+        if (classPath.isValid()) {
+            return classPath;
         }
 
-        return true;
+        log.debug("Classpath is not valid");
+        
+        return null;
     }
 }
\ No newline at end of file

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

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathCache.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

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

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/resources/META-INF/spring/components.xml?rev=706676&r1=706675&r2=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/resources/META-INF/spring/components.xml
Tue Oct 21 09:20:29 2008
@@ -35,10 +35,9 @@
 
     <bean id="applicationManager" class="org.apache.geronimo.gshell.wisdom.application.ApplicationManagerImpl">
         <constructor-arg ref="eventManager"/>
-        <constructor-arg ref="ivy"/>
     </bean>
 
-    <bean id="application" class="org.apache.geronimo.gshell.wisdom.application.ApplicationFactoryBean">
+    <bean id="application" class="org.apache.geronimo.gshell.wisdom.application.ApplicationFactoryBean"
lazy-init="true">
         <constructor-arg ref="applicationManager"/>
     </bean>
 

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java?rev=706676&r1=706675&r2=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
Tue Oct 21 09:20:29 2008
@@ -33,9 +33,8 @@
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.application.ApplicationConfiguredEvent;
+import org.apache.geronimo.gshell.wisdom.application.ClassPathCache;
 import org.apache.geronimo.gshell.wisdom.application.ClassPathImpl;
-import org.apache.geronimo.gshell.xstore.XStore;
-import org.apache.geronimo.gshell.xstore.XStoreRecord;
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
@@ -49,6 +48,7 @@
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.PostConstruct;
+import java.io.File;
 import java.net.URL;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -70,25 +70,17 @@
 
     private final EventPublisher eventPublisher;
 
-    private final XStore xstore;
-
-    private final Ivy ivy;
-
     private BeanContainer container;
 
     private Set<Plugin> plugins = new LinkedHashSet<Plugin>();
 
-    public PluginManagerImpl(final ApplicationManager applicationManager, final EventManager
eventManager, final EventPublisher eventPublisher, final XStore xstore, final Ivy ivy) {
+    public PluginManagerImpl(final ApplicationManager applicationManager, final EventManager
eventManager, final EventPublisher eventPublisher) {
         assert applicationManager != null;
         this.applicationManager = applicationManager;
         assert eventManager != null;
         this.eventManager = eventManager;
         assert eventPublisher != null;
         this.eventPublisher = eventPublisher;
-        assert xstore != null;
-        this.xstore = xstore;
-        assert ivy != null;
-        this.ivy = ivy;
     }
 
     public void setBeanContainer(final BeanContainer container) {
@@ -172,26 +164,15 @@
         assert application != null;
         assert artifact != null;
 
-        ClassPath classPath = null;
-        // FIXME: Get state directory from application/branding
-        XStoreRecord record = xstore.resolveRecord(artifact.getGroupId() + "/" + artifact.getArtifactId()
+ "/classpath.xml");
-        if (record.exists()) {
-            classPath = record.get(ClassPathImpl.class);
-            log.debug("Loaded classpath from cache: {}", record);
-
-            if (!classPath.isValid()) {
-                classPath = null;
-                log.debug("Classpath is not valid; reloading");
-            }
-        }
+        // FIXME: Get basedir from application
+        ClassPathCache cache = new ClassPathCache(new File(new File(System.getProperty("gshell.home")),
"var/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/classpath.ser"));
+        ClassPath classPath = cache.get();
 
         if (classPath == null) {
             Set<Artifact> artifacts = resolveArtifacts(application, artifact);
             classPath = new ClassPathImpl(artifacts);
-            log.debug("Saving classpath to cache: {}", record);
-            record.set(classPath);
+            cache.set(classPath);
         }
-        record.close();
 
         if (log.isDebugEnabled()) {
             log.debug("Plugin classpath:");
@@ -226,6 +207,8 @@
 
         StopWatch watch = new StopWatch(true);
 
+        Ivy ivy = container.getBean("ivy", Ivy.class);
+        
         ResolveReport resolveReport = ivy.resolve(md, options);
 
         log.debug("Resolve completed in: {}", watch);

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=706676&r1=706675&r2=706676&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
Tue Oct 21 09:20:29 2008
@@ -27,19 +27,15 @@
 
     <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
 
-    <bean id="xstore" class="org.apache.geronimo.gshell.xstore.XStoreImpl">
+    <bean id="xstore" class="org.apache.geronimo.gshell.xstore.XStoreImpl" lazy-init="true">
         <constructor-arg ref="fileSystemAccess"/>
         <property name="rootUri"  value="file:${gshell.home}/var/xstore"/>
     </bean>
 
-    <bean id="commandLineParser" class="org.apache.geronimo.gshell.parser.CommandLineParser"/>
-    
     <bean id="pluginManager" class="org.apache.geronimo.gshell.wisdom.plugin.PluginManagerImpl">
         <constructor-arg ref="applicationManager"/>
         <constructor-arg ref="eventManager"/>
         <constructor-arg ref="eventManager"/>
-        <constructor-arg ref="xstore"/>
-        <constructor-arg ref="ivy"/>
     </bean>
 
     <bean id="pluginMetaMapper" class="org.apache.geronimo.gshell.wisdom.plugin.PluginMetaMapper">
@@ -77,6 +73,8 @@
 
     <bean class="org.apache.geronimo.gshell.wisdom.command.GroupCommand" scope="prototype"/>
 
+    <bean id="commandLineParser" class="org.apache.geronimo.gshell.parser.CommandLineParser"/>
+
     <bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl">
         <constructor-arg ref="commandLineParser"/>
     </bean>



Mime
View raw message