geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r703783 - in /geronimo/gshell/trunk: gshell-application/src/main/java/org/apache/geronimo/gshell/application/ gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/ gshell-wisdom/gshell-wisdom-bootstrap/ gshell-wisd...
Date Sun, 12 Oct 2008 10:34:11 GMT
Author: jdillon
Date: Sun Oct 12 03:34:10 2008
New Revision: 703783

URL: http://svn.apache.org/viewvc?rev=703783&view=rev
Log:
Caching the resolved classpath muck for app+plugins under ${gshell.home}/var, re-using the
cache if its there to avoid re-resolving each time

Added:
    geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
  (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/Application.java
    geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java

Modified: geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/Application.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/Application.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/Application.java
(original)
+++ geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/Application.java
Sun Oct 12 03:34:10 2008
@@ -19,14 +19,12 @@
 
 package org.apache.geronimo.gshell.application;
 
+import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
-import org.apache.geronimo.gshell.model.common.Artifact;
-import org.apache.geronimo.gshell.command.Variables;
 
 import java.io.File;
 import java.net.InetAddress;
-import java.util.Set;
 
 /**
  * Encapsulates the context for an application.
@@ -43,7 +41,7 @@
     
     ApplicationModel getModel();
 
-    Set<Artifact> getArtifacts();
+    ClassPath getClassPath();
     
     /**
      * Returns the home directory of the shell.

Added: geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java?rev=703783&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
(added)
+++ geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
Sun Oct 12 03:34:10 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.application;
+
+import org.apache.geronimo.gshell.model.common.Artifact;
+
+import java.net.URL;
+import java.util.Collection;
+
+/**
+ * Provides details about a classpath configuration.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ClassPath
+{
+    Collection<URL> getUrls();
+
+    Collection<Artifact> getArtifacts();
+}
\ No newline at end of file

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

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

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

Modified: geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
(original)
+++ geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/plugin/Plugin.java
Sun Oct 12 03:34:10 2008
@@ -19,10 +19,8 @@
 
 package org.apache.geronimo.gshell.application.plugin;
 
+import org.apache.geronimo.gshell.application.ClassPath;
 import org.apache.geronimo.gshell.model.application.PluginArtifact;
-import org.apache.geronimo.gshell.model.common.Artifact;
-
-import java.util.Set;
 
 /**
  * Plugin.
@@ -35,7 +33,7 @@
 
     PluginArtifact getArtifact();
 
-    Set<Artifact> getArtifacts();
+    ClassPath getClassPath();
 
     /*
     boolean isEnabled();

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml Sun Oct 12 03:34:10
2008
@@ -62,6 +62,11 @@
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-event</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-marshal</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
Sun Oct 12 03:34:10 2008
@@ -65,6 +65,7 @@
             "gshell-interpolation",
             "jcl104-over-slf4j",
             "gshell-terminal",
+            "gshell-marshal",
             "jline",
             "log4j",
             "maven-artifact",

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationImpl.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationImpl.java
Sun Oct 12 03:34:10 2008
@@ -21,18 +21,16 @@
 
 import org.apache.geronimo.gshell.application.Application;
 import org.apache.geronimo.gshell.application.ApplicationConfiguration;
+import org.apache.geronimo.gshell.application.ClassPath;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
-import org.apache.geronimo.gshell.model.common.Artifact;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
-import java.util.LinkedHashSet;
-import java.util.Set;
 
 /**
  * Event fired once the application has constructed a shell.
@@ -46,7 +44,7 @@
 
     private final ApplicationConfiguration config;
 
-    private Set<Artifact> artifacts;
+    private ClassPath classPath;
 
     private InetAddress localHost;
 
@@ -72,33 +70,17 @@
         return config.getVariables();
     }
 
-    public Set<Artifact> getArtifacts() {
-        if (artifacts == null) {
-            throw new IllegalStateException("Artifacts not initialized");
+    public ClassPath getClassPath() {
+        if (classPath == null) {
+            throw new IllegalStateException("Classpath not initialized");
         }
-        return artifacts;
+        return classPath;
     }
 
-    void initArtifacts(final Set<org.apache.maven.artifact.Artifact> artifacts) {
-        assert artifacts != null;
+    void initClassPath(final ClassPath classPath) {
+        assert classPath != null;
 
-        Set<Artifact> set = new LinkedHashSet<Artifact>();
-
-        log.debug("Application artifacts:");
-
-        for (org.apache.maven.artifact.Artifact source : artifacts) {
-            Artifact artifact = new Artifact();
-            artifact.setGroupId(source.getGroupId());
-            artifact.setArtifactId(source.getArtifactId());
-            artifact.setType(source.getType());
-            artifact.setVersion(source.getVersion());
-            
-            log.debug("    {}", artifact.getId());
-
-            set.add(artifact);
-        }
-
-        this.artifacts = set;
+        this.classPath = classPath;
     }
 
     public ApplicationModel getModel() {

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=703783&r1=703782&r2=703783&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
Sun Oct 12 03:34:10 2008
@@ -23,10 +23,14 @@
 import org.apache.geronimo.gshell.application.ApplicationConfiguration;
 import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.application.ApplicationSecurityManager;
+import org.apache.geronimo.gshell.application.ClassPath;
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.geronimo.gshell.event.EventPublisher;
+import org.apache.geronimo.gshell.marshal.MarshallerSupport;
+import org.apache.geronimo.gshell.marshal.Marshaller;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
 import org.apache.geronimo.gshell.model.application.DependencyArtifact;
 import org.apache.geronimo.gshell.model.common.LocalRepository;
@@ -37,7 +41,6 @@
 import org.apache.geronimo.gshell.shell.Shell;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -52,11 +55,10 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.net.URL;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.net.URL;
 
 /**
  * Default implementation of the {@link ApplicationManager} component.
@@ -169,20 +171,15 @@
         StopWatch watch = new StopWatch(true);
 
         ApplicationImpl app = new ApplicationImpl(config);
-
         ApplicationModel model = app.getModel();
 
         log.debug("Loading application: {}", app.getId());
         log.trace("Application model: {}", model);
 
-        Set<Artifact> artifacts = resolveArtifacts(model);
+        ClassPath classPath = loadClassPath(model);
+        app.initClassPath(classPath);
 
-        // Initialize the applications artifact configuration
-        app.initArtifacts(artifacts);
-
-        List<URL> classPath = createClassPath(artifacts);
-
-        BeanContainer child = container.createChild("gshell.application(" + model.getId()
+ ")", classPath);
+        BeanContainer child = container.createChild("gshell.application(" + model.getId()
+ ")", classPath.getUrls());
         log.debug("Application container: {}", child);
 
         child.loadBeans(new String[] {
@@ -196,6 +193,36 @@
         return app;
     }
 
+    private ClassPath loadClassPath(final ApplicationModel model) throws Exception {
+        assert model != null;
+
+        Marshaller<ClassPath> marshaller = new MarshallerSupport<ClassPath>(ClassPathImpl.class);
+        File file = new File(new File(System.getProperty("gshell.home")), "var/gshell/classpath.xml");
 // FIXME: Get state directory from application/branding
+        ClassPath classPath;
+
+        if (file.exists()) {
+            classPath = marshaller.unmarshal(file);
+            log.debug("Loaded classpath from cache: {}", file);
+        }
+        else {
+            Set<Artifact> artifacts = resolveArtifacts(model);
+            classPath = new ClassPathImpl(artifacts);
+            log.debug("Saving classpath to cache: {}", file);
+            file.getParentFile().mkdirs();
+            marshaller.marshal(classPath, file);
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Application classpath:");
+
+            for (URL url : classPath.getUrls()) {
+                log.debug("    {}", url);
+            }
+        }
+
+        return classPath;
+    }
+
     private Set<Artifact> resolveArtifacts(final ApplicationModel model) throws Exception
{
         assert model != null;
 
@@ -230,28 +257,6 @@
         return result.getArtifacts();
     }
 
-    private List<URL> createClassPath(final Set<Artifact> artifacts) throws Exception
{
-        assert artifacts != null;
-
-        List<URL> classPath = new LinkedList<URL>();
-
-        if (!artifacts.isEmpty()) {
-            log.debug("Application classpath:");
-
-            for (Artifact artifact : artifacts) {
-                File file = artifact.getFile();
-                assert file != null;
-
-                URL url = file.toURI().toURL();
-                log.debug("    {}", url);
-
-                classPath.add(url);
-            }
-        }
-
-        return classPath;
-    }
-
     //
     // ShellFactory
     //

Added: 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/ClassPathImpl.java?rev=703783&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
Sun Oct 12 03:34:10 2008
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+import com.thoughtworks.xstream.annotations.XStreamAlias;
+import org.apache.geronimo.gshell.application.ClassPath;
+import org.apache.geronimo.gshell.model.common.Artifact;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * {@link ClassPath} implementation backed up by a set of Maven artifacts.
+ *
+ * @version $Rev$ $Date$
+ */
+@XStreamAlias("classpath")
+public class ClassPathImpl
+    implements ClassPath
+{
+    private Collection<URL> urls;
+
+    private Collection<Artifact> artifacts;
+
+    public ClassPathImpl() {}
+    
+    public ClassPathImpl(final Set<org.apache.maven.artifact.Artifact> artifacts) {
+        assert artifacts != null;
+
+        this.artifacts = new LinkedHashSet<Artifact>();
+        this.urls = new LinkedHashSet<URL>();
+
+        for (org.apache.maven.artifact.Artifact source : artifacts) {
+            Artifact artifact = new Artifact();
+            artifact.setGroupId(source.getGroupId());
+            artifact.setArtifactId(source.getArtifactId());
+            artifact.setType(source.getType());
+            artifact.setVersion(source.getVersion());
+
+            try {
+                File file = source.getFile();
+                if (file == null) {
+                    throw new IllegalStateException("Artifact missing resolved local-file:
" + source);
+                }
+
+                //
+                // TODO: Need to make this handle when ${gshell.home} is moved, so we can
still re-use the cache.
+                //       Also need to, when unmarshalling, validate that the files still
exist and invalidate if not
+                //
+                
+                URL url = file.toURI().toURL();
+                this.urls.add(url);
+            }
+            catch (MalformedURLException e) {
+                throw new RuntimeException(e);
+            }
+
+            this.artifacts.add(artifact);
+        }
+    }
+
+    public Collection<URL> getUrls() {
+        assert urls != null;
+        return Collections.unmodifiableCollection(urls);
+    }
+
+    public Collection<Artifact> getArtifacts() {
+        assert artifacts != null;
+        return Collections.unmodifiableCollection(artifacts);
+    }
+}
\ No newline at end of file

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

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.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/ClassPathImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/pom.xml Sun Oct 12 03:34:10 2008
@@ -72,6 +72,11 @@
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-vfs-meta</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-xstore</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
Sun Oct 12 03:34:10 2008
@@ -50,7 +50,7 @@
         
         // Filter out application artifacts, need to use gid:aid to make sure we don't clober
anything which has the same artifactId, but different groupId
         final Set<String> excludes = new HashSet<String>();
-        for (org.apache.geronimo.gshell.model.common.Artifact a : application.getArtifacts())
{
+        for (org.apache.geronimo.gshell.model.common.Artifact a : application.getClassPath().getArtifacts())
{
             String id = a.getGroupId() + ":" + a.getArtifactId();
             excludes.add(id);
         }

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java?rev=703783&r1=703782&r2=703783&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginImpl.java
Sun Oct 12 03:34:10 2008
@@ -20,6 +20,9 @@
 package org.apache.geronimo.gshell.wisdom.plugin;
 
 import org.apache.geronimo.gshell.application.plugin.Plugin;
+import org.apache.geronimo.gshell.application.Application;
+import org.apache.geronimo.gshell.application.ClassPath;
+import org.apache.geronimo.gshell.model.application.PluginArtifact;
 import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.apache.geronimo.gshell.spring.BeanContainerAware;
 import org.apache.geronimo.gshell.wisdom.plugin.activation.ActivationContext;
@@ -28,8 +31,6 @@
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.Bundle;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
 import org.apache.geronimo.gshell.wisdom.plugin.bundle.NoSuchBundleException;
-import org.apache.geronimo.gshell.model.common.Artifact;
-import org.apache.geronimo.gshell.model.application.PluginArtifact;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,8 +38,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.LinkedHashSet;
 
 /**
  * Default implementation of {@link Plugin}.
@@ -58,7 +57,7 @@
     
     private PluginArtifact artifact;
 
-    private Set<Artifact> artifacts;
+    private ClassPath classPath;
 
     private List<String> bundleNames;
 
@@ -95,35 +94,19 @@
         this.artifact = artifact;
     }
 
-    public Set<Artifact> getArtifacts() {
-        if (artifacts == null) {
-            throw new IllegalStateException("Artifacts not initialized");
+    public ClassPath getClassPath() {
+        if (classPath == null) {
+            throw new IllegalStateException("Classpath not initialized");
         }
-        return artifacts;
+        return classPath;
     }
 
-    void initArtifacts(final Set<org.apache.maven.artifact.Artifact> artifacts) {
-        assert artifacts != null;
-
-        Set<Artifact> set = new LinkedHashSet<Artifact>();
-
-        log.debug("Plugin artifacts:");
-
-        for (org.apache.maven.artifact.Artifact source : artifacts) {
-            Artifact artifact = new Artifact();
-            artifact.setGroupId(source.getGroupId());
-            artifact.setArtifactId(source.getArtifactId());
-            artifact.setType(source.getType());
-            artifact.setVersion(source.getVersion());
+    void initClassPath(final ClassPath classPath) {
+        assert classPath != null;
 
-            log.debug("    {}", artifact.getId());
-
-            set.add(artifact);
-        }
-
-        this.artifacts = set;
+        this.classPath = classPath;
     }
-
+    
     public List<String> getBundleNames() {
         List<String> list = bundleNames;
 

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=703783&r1=703782&r2=703783&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
Sun Oct 12 03:34:10 2008
@@ -21,18 +21,22 @@
 
 import org.apache.geronimo.gshell.application.Application;
 import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.application.ClassPath;
 import org.apache.geronimo.gshell.application.plugin.Plugin;
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.chronos.StopWatch;
 import org.apache.geronimo.gshell.event.Event;
 import org.apache.geronimo.gshell.event.EventListener;
 import org.apache.geronimo.gshell.event.EventManager;
 import org.apache.geronimo.gshell.event.EventPublisher;
+import org.apache.geronimo.gshell.marshal.MarshallerSupport;
+import org.apache.geronimo.gshell.marshal.Marshaller;
 import org.apache.geronimo.gshell.model.application.PluginArtifact;
 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.chronos.StopWatch;
+import org.apache.geronimo.gshell.wisdom.application.ClassPathImpl;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -43,11 +47,10 @@
 
 import javax.annotation.PostConstruct;
 import java.io.File;
-import java.net.URL;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.net.URL;
 
 /**
  * Default implementation of the {@link PluginManager} component.
@@ -126,10 +129,9 @@
 
         log.debug("Loading plugin: {}", artifact.getId());
 
-        Set<Artifact> artifacts = resolveArtifacts(application, artifact);
-        List<URL> classPath = createClassPath(artifacts);
-
-        BeanContainer pluginContainer = container.createChild("gshell.plugin(" + artifact.getId()
+ ")", classPath);
+        ClassPath classPath = loadClassPath(application, artifact);
+        
+        BeanContainer pluginContainer = container.createChild("gshell.plugin(" + artifact.getId()
+ ")", classPath.getUrls());
         log.debug("Created plugin container: {}", pluginContainer);
 
         pluginContainer.loadBeans(new String[] {
@@ -140,7 +142,7 @@
 
         // Initialize the plugins artifact configuration
         plugin.initArtifact(artifact);
-        plugin.initArtifacts(artifacts);
+        plugin.initClassPath(classPath);
 
         plugins.add(plugin);
 
@@ -153,6 +155,37 @@
         eventPublisher.publish(new PluginLoadedEvent(plugin, artifact));
     }
 
+    private ClassPath loadClassPath(final Application application, final PluginArtifact artifact)
throws Exception {
+        assert application != null;
+        assert artifact != null;
+
+        Marshaller<ClassPath> marshaller = new MarshallerSupport<ClassPath>(ClassPathImpl.class);
+        File file = new File(new File(System.getProperty("gshell.home")), "var/gshell/" +
artifact.getGroupId() + "/" + artifact.getArtifactId() + "/classpath.xml");  // FIXME: Get
state directory from application/branding
+        ClassPath classPath;
+
+        if (file.exists()) {
+            classPath = marshaller.unmarshal(file);
+            log.debug("Loaded classpath from cache: {}", file);
+        }
+        else {
+            Set<Artifact> artifacts = resolveArtifacts(application, artifact);
+            classPath = new ClassPathImpl(artifacts);
+            log.debug("Saving classpath to cache: {}", file);
+            file.getParentFile().mkdirs();
+            marshaller.marshal(classPath, file);
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Plugin classpath:");
+
+            for (URL url : classPath.getUrls()) {
+                log.debug("    {}", url);
+            }
+        }
+
+        return classPath;
+    }
+
     public void loadPlugin(final PluginArtifact artifact) throws Exception {
         assert applicationManager != null;
         loadPlugin(applicationManager.getApplication(), artifact);
@@ -184,26 +217,4 @@
 
         return result.getArtifacts();
     }
-
-    private List<URL> createClassPath(final Set<Artifact> artifacts) throws Exception
{
-        assert artifacts != null;
-
-        List<URL> classPath = new LinkedList<URL>();
-
-        if (!artifacts.isEmpty()) {
-            log.debug("Plugin classpath:");
-
-            for (Artifact a : artifacts) {
-                File file = a.getFile();
-                assert file != null;
-
-                URL url = file.toURI().toURL();
-                log.debug("    {}", url);
-
-                classPath.add(url);
-            }
-        }
-
-        return classPath;
-    }
 }
\ No newline at end of file



Mime
View raw message