geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r700050 - in /geronimo/gshell/trunk/gshell-wisdom: gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/
Date Mon, 29 Sep 2008 10:42:24 GMT
Author: jdillon
Date: Mon Sep 29 03:42:21 2008
New Revision: 700050

URL: http://svn.apache.org/viewvc?rev=700050&view=rev
Log:
Expose the artifacts used to build classpath for application and plugin
Expose the source artifact for plugins
Created ApplicationArtifactFilter and PluginArtifactFilter to handle the filtering of muck,
and share some muck too

Added:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
  (with props)
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
  (with props)
Modified:
    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/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

Added: 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=700050&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationArtifactFilter.java
Mon Sep 29 03:42:21 2008
@@ -0,0 +1,105 @@
+/*
+ * 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 org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+
+/**
+ * Artifact filter for applications.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ApplicationArtifactFilter
+    implements ArtifactFilter
+{
+    private ArtifactFilter delegate;
+
+    protected AndArtifactFilter createFilter() {
+        AndArtifactFilter filter = new AndArtifactFilter();
+
+        filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
+
+        // Exclude bootstrap classes (stuff which lives in ${gshell.home}/lib
+        filter.add(new ExclusionSetFilter(new String[] {
+            //
+            // FIXME: Load this list from build-generated properties or something like that
+            //
+
+            "aopalliance",
+            "aspectjrt",
+            "geronimo-annotation_1.0_spec",
+            "gshell-ansi",
+            "gshell-api",
+            "gshell-artifact",
+            "gshell-application",
+            "gshell-cli",
+            "gshell-clp",
+            "gshell-chronos",
+            "gshell-i18n",
+            "gshell-io",
+            "gshell-model",
+            "gshell-spring",
+            "gshell-wisdom-bootstrap",
+            "gshell-yarn",
+            "gshell-interpolation",
+            "jcl104-over-slf4j",
+            "gshell-terminal",
+            "jline",
+            "log4j",
+            "maven-artifact",
+            "maven-model",
+            "maven-profile",
+            "maven-project",
+            "maven-workspace",
+            "maven-settings",
+            "maven-plugin-registry",
+            "plexus-component-annotations",
+            "plexus-container-default",
+            "plexus-interpolation",
+            "plexus-utils",
+            "plexus-classworlds",
+            "slf4j-api",
+            "slf4j-log4j12",
+            "spring-core",
+            "spring-context",
+            "spring-beans",
+            "wagon-file",
+            "wagon-http-lightweight",
+            "wagon-http-shared",
+            "wagon-provider-api",
+            "xbean-reflect",
+            "xstream",
+        }));
+
+        return filter;
+    }
+
+    public final boolean include(final Artifact artifact) {
+        if (delegate == null) {
+            delegate = createFilter();
+        }
+        
+        return delegate.include(artifact);
+    }
+}

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

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

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=700050&r1=700049&r2=700050&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
Mon Sep 29 03:42:21 2008
@@ -24,13 +24,15 @@
 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.net.UnknownHostException;
+import java.util.Set;
+import java.util.LinkedHashSet;
 
 /**
  * Event fired once the application has constructed a shell.
@@ -44,6 +46,8 @@
 
     private final ApplicationConfiguration config;
 
+    private Set<Artifact> artifacts;
+
     private InetAddress localHost;
 
     private File homeDir;
@@ -68,6 +72,35 @@
         return config.getVariables();
     }
 
+    public Set<Artifact> getArtifacts() {
+        if (artifacts == null) {
+            throw new IllegalStateException("Artifacts not initialized");
+        }
+        return artifacts;
+    }
+
+    void initArtifacts(final Set<org.apache.maven.artifact.Artifact> artifacts) {
+        assert artifacts != 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;
+    }
+
     public ApplicationModel getModel() {
         return config.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=700050&r1=700049&r2=700050&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
Mon Sep 29 03:42:21 2008
@@ -25,9 +25,7 @@
 import org.apache.geronimo.gshell.application.ApplicationSecurityManager;
 import org.apache.geronimo.gshell.application.settings.SettingsManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
-import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.event.EventPublisher;
-import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.ApplicationModel;
 import org.apache.geronimo.gshell.model.application.DependencyArtifact;
 import org.apache.geronimo.gshell.model.common.LocalRepository;
@@ -42,9 +40,6 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -111,11 +106,10 @@
         // Interpolate the model
         interpolate(config);
 
-        // Configure the application
-        configure(config.getModel());
+        // Apply artifact manager configuration settings for application
+        configureArtifactManager(config.getModel());
 
-        // Create a new context
-        application = new ApplicationImpl(config);
+        application = loadApplication(config);
 
         log.debug("Application configured");
         
@@ -147,20 +141,6 @@
         config.setModel(model);
     }
 
-    private void configure(final ApplicationModel model) throws Exception {
-        assert model != null;
-
-        log.debug("Application ID: {}", model.getId());
-        log.trace("Application descriptor: {}", model);
-
-        // Apply artifact manager configuration settings for application
-        configureArtifactManager(model);
-
-        // Create the application container
-        applicationContainer = createContainer(model);
-        applicationContainer.start();
-    }
-
     private void configureArtifactManager(final ApplicationModel model) throws Exception
{
         assert model != null;
         assert artifactManager != null;
@@ -178,87 +158,47 @@
         }
     }
 
-    private BeanContainer createContainer(final ApplicationModel model) throws Exception
{
-        assert model != null;
+    private ApplicationImpl loadApplication(final ApplicationConfiguration config) throws
Exception {
+        assert config != null;
 
-        log.debug("Creating application container");
+        ApplicationImpl app = new ApplicationImpl(config);
 
-        List<URL> classPath = createClassPath(model);
+        ApplicationModel model = app.getModel();
 
-        BeanContainer child = container.createChild("gshell.application[" + model.getId()
+ "]", classPath);
+        log.debug("Loading application: {}", app.getId());
+        log.trace("Application model: {}", model);
 
-        log.debug("Application container: {}", child);
+        Set<Artifact> artifacts = resolveArtifacts(model);
 
-        return child;
-    }
+        // Initialize the applications artifact configuration
+        app.initArtifacts(artifacts);
 
-    private List<URL> createClassPath(final ApplicationModel model) throws Exception
{
-        assert model != null;
+        List<URL> classPath = createClassPath(artifacts);
 
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+        BeanContainer child = container.createChild("gshell.application(" + model.getId()
+ ")", classPath);
 
-        AndArtifactFilter filter = new AndArtifactFilter();
+        log.debug("Application container: {}", child);
 
-        filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
+        child.start();
 
-        filter.add(new ExclusionSetFilter(new String[] {
-            //
-            // FIXME: Load this list from build-generated properties or something like that
-            //
+        applicationContainer = child;
+
+        return app;
+    }
 
-            "aopalliance",
-            "aspectjrt",
-            "geronimo-annotation_1.0_spec",
-            "gshell-ansi",
-            "gshell-api",
-            "gshell-artifact",
-            "gshell-application",
-            "gshell-cli",
-            "gshell-clp",
-            "gshell-chronos",
-            "gshell-i18n",
-            "gshell-io",
-            "gshell-model",
-            "gshell-spring",
-            "gshell-wisdom-bootstrap",
-            "gshell-yarn",
-            "gshell-interpolation",
-            "jcl104-over-slf4j",
-            "gshell-terminal",
-            "jline",
-            "log4j",
-            "maven-artifact",
-            "maven-model",
-            "maven-profile",
-            "maven-project",
-            "maven-workspace",
-            "maven-settings",
-            "maven-plugin-registry",
-            "plexus-component-annotations",
-            "plexus-container-default",
-            "plexus-interpolation",
-            "plexus-utils",
-            "plexus-classworlds",
-            "slf4j-api",
-            "slf4j-log4j12",
-            "spring-core",
-            "spring-context",
-            "spring-beans",
-            "wagon-file",
-            "wagon-http-lightweight",
-            "wagon-http-shared",
-            "wagon-provider-api",
-            "xbean-reflect",
-            "xpp3_min",
-            "xstream",
-        }));
+    private Set<Artifact> resolveArtifacts(final ApplicationModel model) throws Exception
{
+        assert model != null;
+
+        log.debug("Resolving application artifacts");
 
-        request.setFilter(filter);
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+        request.setFilter(new ApplicationArtifactFilter());
 
         Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
         List<DependencyArtifact> dependencies = model.getDependencies(true); // include
groups
 
         if (!dependencies.isEmpty()) {
+            assert artifactManager != null;
             ArtifactFactory factory = artifactManager.getArtifactFactory();
 
             log.debug("Application dependencies:");
@@ -267,7 +207,7 @@
                 Artifact artifact = factory.createArtifact(dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), /*scope*/null, dep.getType());
                 assert artifact != null;
 
-                log.debug(" + {}", artifact);
+                log.debug("    {}", artifact);
 
                 artifacts.add(artifact);
             }
@@ -277,18 +217,23 @@
 
         ArtifactResolutionResult result = artifactManager.resolve(request);
 
+        return result.getArtifacts();
+    }
+
+    private List<URL> createClassPath(final Set<Artifact> artifacts) throws Exception
{
+        assert artifacts != null;
+
         List<URL> classPath = new LinkedList<URL>();
-        Set<Artifact> resolvedArtifacts = result.getArtifacts();
 
-        if (resolvedArtifacts != null && !resolvedArtifacts.isEmpty()) {
+        if (!artifacts.isEmpty()) {
             log.debug("Application classpath:");
 
-            for (Artifact artifact : resolvedArtifacts) {
+            for (Artifact artifact : artifacts) {
                 File file = artifact.getFile();
                 assert file != null;
 
                 URL url = file.toURI().toURL();
-                log.debug(" + {}", url);
+                log.debug("    {}", url);
 
                 classPath.add(url);
             }

Added: 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=700050&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
Mon Sep 29 03:42:21 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.plugin;
+
+import org.apache.geronimo.gshell.wisdom.application.ApplicationArtifactFilter;
+import org.apache.geronimo.gshell.application.Application;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.Artifact;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Artifact filter for plugins.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PluginArtifactFilter
+    extends ApplicationArtifactFilter
+{
+    private final Application application;
+
+    public PluginArtifactFilter(final Application application) {
+        assert application != null;
+
+        this.application = application;
+    }
+
+    @Override
+    protected AndArtifactFilter createFilter() {
+        AndArtifactFilter filter = super.createFilter();
+        
+        // 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())
{
+            String id = a.getGroupId() + ":" + a.getArtifactId();
+            excludes.add(id);
+        }
+
+        filter.add(new ArtifactFilter() {
+            public boolean include(final Artifact artifact) {
+                assert artifact != null;
+                String id = artifact.getGroupId() + ":" + artifact.getArtifactId();
+                return !excludes.contains(id);
+            }
+        });
+
+        return filter;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginArtifactFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=700050&r1=700049&r2=700050&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
Mon Sep 29 03:42:21 2008
@@ -28,6 +28,8 @@
 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;
 
@@ -35,6 +37,8 @@
 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}.
@@ -48,7 +52,13 @@
 
     private final String name;
 
+    /*
     private boolean enabled = false;
+    */
+    
+    private PluginArtifact artifact;
+
+    private Set<Artifact> artifacts;
 
     private List<String> bundleNames;
 
@@ -72,6 +82,48 @@
         return name;
     }
 
+    public PluginArtifact getArtifact() {
+        if (artifact == null) {
+            throw new IllegalStateException("Artifact not initialized");
+        }
+        return artifact;
+    }
+
+    void initArtifact(final PluginArtifact artifact) {
+        assert artifact != null;
+        
+        this.artifact = artifact;
+    }
+
+    public Set<Artifact> getArtifacts() {
+        if (artifacts == null) {
+            throw new IllegalStateException("Artifacts not initialized");
+        }
+        return artifacts;
+    }
+
+    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());
+
+            log.debug("    {}", artifact.getId());
+
+            set.add(artifact);
+        }
+
+        this.artifacts = set;
+    }
+
     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=700050&r1=700049&r2=700050&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
Mon Sep 29 03:42:21 2008
@@ -20,6 +20,7 @@
 package org.apache.geronimo.gshell.wisdom.plugin;
 
 import org.apache.geronimo.gshell.application.Application;
+import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.apache.geronimo.gshell.application.plugin.Plugin;
 import org.apache.geronimo.gshell.application.plugin.PluginManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
@@ -35,9 +36,6 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +59,9 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Autowired
+    private ApplicationManager applicationManager;
+
+    @Autowired
     private ArtifactManager artifactManager;
 
     @Autowired
@@ -79,9 +80,8 @@
         this.container = container;
     }
 
-    @SuppressWarnings({"UnusedDeclaration"})
     @PostConstruct
-    private void init() {
+    public void init() {
         assert eventManager != null;
         eventManager.addListener(new EventListener() {
             public void onEvent(Event event) throws Exception {
@@ -109,7 +109,7 @@
 
         for (PluginArtifact artifact : artifacts) {
             try {
-                loadPlugin(artifact);
+                loadPlugin(application, artifact);
             }
             catch (Exception e) {
                 log.error("Failed to load plugin: " + artifact, e);
@@ -117,19 +117,25 @@
         }
     }
 
-    public void loadPlugin(final PluginArtifact artifact) throws Exception {
+    private void loadPlugin(final Application application, final PluginArtifact artifact)
throws Exception {
+        assert application != null;
         assert artifact != null;
 
         log.debug("Loading plugin: {}", artifact.getId());
 
-        List<URL> classPath = createClassPath(artifact);
+        Set<Artifact> artifacts = resolveArtifacts(application, artifact);
+        List<URL> classPath = createClassPath(artifacts);
 
-        BeanContainer pluginContainer = container.createChild("gshell.plugin[" + artifact.getId()
+ "]", classPath);
+        BeanContainer pluginContainer = container.createChild("gshell.plugin(" + artifact.getId()
+ ")", classPath);
         pluginContainer.start();
         
         log.debug("Created plugin container: {}", pluginContainer);
         
-        Plugin plugin = pluginContainer.getBean(Plugin.class);
+        PluginImpl plugin = pluginContainer.getBean(PluginImpl.class);
+
+        // Initialize the plugins artifact configuration
+        plugin.initArtifact(artifact);
+        plugin.initArtifacts(artifacts);
 
         plugins.add(plugin);
 
@@ -140,50 +146,22 @@
         eventPublisher.publish(new PluginLoadedEvent(plugin, artifact));
     }
 
-    private List<URL> createClassPath(final PluginArtifact artifact) throws Exception
{
-        assert artifact != null;
-
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
-
-        AndArtifactFilter filter = new AndArtifactFilter();
+    public void loadPlugin(final PluginArtifact artifact) throws Exception {
+        assert applicationManager != null;
+        loadPlugin(applicationManager.getApplication(), artifact);
+    }
 
-        filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
+    private Set<Artifact> resolveArtifacts(final Application application, final PluginArtifact
artifact) throws Exception {
+        assert application != null;
+        assert artifact != null;
 
-        //
-        // FIXME: Need to inherit some of this crap from the applications exclusions!
-        //
+        log.debug("Resolving plugin artifacts");
         
-        filter.add(new ExclusionSetFilter(new String[] {
-            "aopalliance",
-            "geronimo-annotation_1.0_spec",
-            "gshell-ansi",
-            "gshell-api",
-            "gshell-application",
-            "gshell-clp",
-            "gshell-i18n",
-            "gshell-io",
-            "gshell-model",
-            "gshell-spring",
-            "gshell-yarn",
-            "gshell-interpolation",
-            "gshell-layout",
-            "gshell-terminal",
-            "gshell-console",
-            "gshell-chronos",
-            "jcl104-over-slf4j",
-            "jline",
-            "plexus-classworlds",
-            "slf4j-api",
-            "spring-core",
-            "spring-context",
-            "spring-beans",
-            "xpp3_min",
-            "xstream",
-        }));
-
-        request.setFilter(filter);
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+        request.setFilter(new PluginArtifactFilter(application));
 
         Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+        assert artifactManager != null;
         ArtifactFactory factory = artifactManager.getArtifactFactory();
 
         Artifact pluginArtifact = factory.createArtifact(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), /*scope*/null, artifact.getType());
@@ -197,18 +175,23 @@
 
         ArtifactResolutionResult result = artifactManager.resolve(request);
 
+        return result.getArtifacts();
+    }
+
+    private List<URL> createClassPath(final Set<Artifact> artifacts) throws Exception
{
+        assert artifacts != null;
+
         List<URL> classPath = new LinkedList<URL>();
-        Set<Artifact> resolvedArtifacts = result.getArtifacts();
 
-        if (resolvedArtifacts != null && !resolvedArtifacts.isEmpty()) {
+        if (!artifacts.isEmpty()) {
             log.debug("Plugin classpath:");
 
-            for (Artifact a : resolvedArtifacts) {
+            for (Artifact a : artifacts) {
                 File file = a.getFile();
                 assert file != null;
 
                 URL url = file.toURI().toURL();
-                log.debug(" + {}", url);
+                log.debug("    {}", url);
 
                 classPath.add(url);
             }



Mime
View raw message