geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r567155 - in /geronimo/server/trunk/modules: geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java
Date Fri, 17 Aug 2007 21:47:40 GMT
Author: djencks
Date: Fri Aug 17 14:47:39 2007
New Revision: 567155

URL: http://svn.apache.org/viewvc?view=rev&rev=567155
Log:
GERONIMO-3415 Make artifact aliasing work for fully resolved artifacts

Modified:
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java?view=diff&rev=567155&r1=567154&r2=567155
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
Fri Aug 17 14:47:39 2007
@@ -16,23 +16,23 @@
  */
 package org.apache.geronimo.kernel.config;
 
-import java.util.List;
-import java.util.Collection;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.Stack;
-import java.io.File;
-import java.net.MalformedURLException;
 
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
-import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Dependency;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Repository;
 
 /**
  * @version $Rev$ $Date$
@@ -40,7 +40,7 @@
 public class ConfigurationResolver {
     private final Artifact configurationId;
     private final ArtifactResolver artifactResolver;
-    private final Collection repositories;
+    private final Collection<? extends Repository> repositories;
 
     /**
      * file or configstore used to resolve classpath parts
@@ -60,14 +60,14 @@
         this.configurationId = configurationId;
         this.baseDir = baseDir;
         artifactResolver = null;
-        repositories = Collections.EMPTY_SET;
+        repositories = Collections.emptySet();
         configurationStore = null;
         moduleName = null;
     }
 
-    public ConfigurationResolver(ConfigurationData configurationData, Collection repositories,
ArtifactResolver artifactResolver) {
+    public ConfigurationResolver(ConfigurationData configurationData, Collection<? extends
Repository> repositories, ArtifactResolver artifactResolver) {
         if (configurationData == null)  throw new NullPointerException("configurationData
is null");
-        if (repositories == null) repositories = Collections.EMPTY_SET;
+        if (repositories == null) repositories = Collections.emptySet();
 
         configurationId = configurationData.getId();
         this.artifactResolver = artifactResolver;
@@ -81,7 +81,7 @@
         moduleName = null;
     }
 
-    private ConfigurationResolver(Artifact configurationId, ArtifactResolver artifactResolver,
Collection repositories, File baseDir, ConfigurationStore configurationStore, String moduleName)
{
+    private ConfigurationResolver(Artifact configurationId, ArtifactResolver artifactResolver,
Collection<? extends Repository> repositories, File baseDir, ConfigurationStore configurationStore,
String moduleName) {
         this.configurationId = configurationId;
         this.artifactResolver = artifactResolver;
         this.repositories = repositories;
@@ -104,8 +104,7 @@
     }
 
     public File resolve(Artifact artifact) throws MissingDependencyException {
-        for (Iterator j = repositories.iterator(); j.hasNext();) {
-            Repository repository = (Repository) j.next();
+        for (Repository repository : repositories) {
             if (repository.contains(artifact)) {
                 File file = repository.getLocation(artifact);
                 return file;
@@ -114,32 +113,32 @@
         throw new MissingDependencyException("Unable to resolve dependency " + artifact);
     }
 
-    public Set resolve(String pattern) throws MalformedURLException, NoSuchConfigException
{
+    public Set<URL> resolve(String pattern) throws MalformedURLException, NoSuchConfigException
{
         if (configurationStore != null) {
-            Set matches = configurationStore.resolve(configurationId, moduleName, pattern);
+            Set<URL> matches = configurationStore.resolve(configurationId, moduleName,
pattern);
             return matches;
         } else if (baseDir != null) {
-            Set matches = IOUtil.search(baseDir, pattern);
+            Set<URL> matches = IOUtil.search(baseDir, pattern);
             return matches;
         } else {
             throw new IllegalStateException("No configurationStore or baseDir supplied so
paths can not be resolved");
         }
     }
 
-    public List resolveTransitiveDependencies(Collection parents, List dependencies) throws
MissingDependencyException {
+    public List<Dependency> resolveTransitiveDependencies(Collection<Configuration>
parents, List<Dependency> dependencies) throws MissingDependencyException {
         Stack<Dependency> parentStack = new Stack<Dependency>();
         return internalResolveTransitiveDependencies(parents, dependencies, parentStack);
     }
 
-    private List internalResolveTransitiveDependencies(Collection parents, List dependencies,
Stack parentStack) throws MissingDependencyException {
-        List resolvedDependencies = new ArrayList();
-        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
-            Dependency dependency = resolveDependency(parents, (Dependency) iterator.next(),
parentStack);
+    private List<Dependency> internalResolveTransitiveDependencies(Collection<Configuration>
parents, List<Dependency> dependencies, Stack<Dependency> parentStack) throws
MissingDependencyException {
+        List<Dependency> resolvedDependencies = new ArrayList<Dependency>();
+        for (Dependency dependency1 : dependencies) {
+            Dependency dependency = resolveDependency(parents, dependency1, parentStack);
 
             if (!resolvedDependencies.contains(dependency)) {
                 resolvedDependencies.add(dependency);
 
-                List childDependencies = getChildDependencies(dependency);
+                List<Dependency> childDependencies = getChildDependencies(dependency);
                 if (!childDependencies.isEmpty()) {
                     parentStack.push(dependency);
                     childDependencies = internalResolveTransitiveDependencies(parents, childDependencies,
parentStack);
@@ -151,16 +150,15 @@
         return resolvedDependencies;
     }
 
-    private Dependency resolveDependency(Collection parents, Dependency dependency, Stack<Dependency>
parentStack) throws MissingDependencyException {
+    private Dependency resolveDependency(Collection<Configuration> parents, Dependency
dependency, Stack<Dependency> parentStack) throws MissingDependencyException {
         Artifact artifact = dependency.getArtifact();
 
-        // if it is already resolved we are done
-        if (artifact.isResolved()) {
-            return dependency;
-        }
-
-        // we need an artifact resolver at this point
+        // we might need an artifact resolver at this point
         if (artifactResolver == null) {
+            // if it is already resolved we are done
+            if (artifact.isResolved()) {
+                return dependency;
+            }
             throw new MissingDependencyException("Artifact is not resolved and there no artifact
resolver available: " + artifact);
         }
         
@@ -171,10 +169,10 @@
             // I'm throwing away the original error as the new message is lost on the stack
as
             // most folks will drill down to the message on the bottom of the stack.
             StringBuffer sb = new StringBuffer();
-            sb.append(e.getMessage().trim()+"\n"+"  Parent stack:\n");
+            sb.append(e.getMessage().trim()).append("\n"+"  Parent stack:\n");
             boolean first = true;
             for (Dependency d  : parentStack) {
-                sb.append("         "+d.getArtifact().toString().trim()+(first?" (top)":"")+"\n");
+                sb.append("         ").append(d.getArtifact().toString().trim()).append((first?"
(top)":"")).append("\n");
                 first = false;
             }
             throw new MissingDependencyException(sb.toString());
@@ -185,17 +183,15 @@
         return resolvedDependency;
     }
 
-    private ArrayList getChildDependencies(Dependency dependency) {
-        ArrayList childDependencies = new ArrayList();
-        for (Iterator repositoryIterator = repositories.iterator(); repositoryIterator.hasNext();)
{
-            Repository repository = (Repository) repositoryIterator.next();
+    private ArrayList<Dependency> getChildDependencies(Dependency dependency) {
+        ArrayList<Dependency> childDependencies = new ArrayList<Dependency>();
+        for (Repository repository : repositories) {
             if (repository.contains(dependency.getArtifact())) {
                 // get the child artifacts
-                LinkedHashSet childArtifacts = repository.getDependencies(dependency.getArtifact());
-                for (Iterator artifactIterator = childArtifacts.iterator(); artifactIterator.hasNext();)
{
-                    Artifact artifact = (Artifact) artifactIterator.next();
+                LinkedHashSet<Artifact> childArtifacts = repository.getDependencies(dependency.getArtifact());
+                for (Artifact artifact : childArtifacts) {
                     // add each child as a classes-only dependency
-                    childDependencies.add(new Dependency(artifact,  ImportType.CLASSES));
+                    childDependencies.add(new Dependency(artifact, ImportType.CLASSES));
                 }
             }
         }

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java?view=diff&rev=567155&r1=567154&r2=567155
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java
Fri Aug 17 14:47:39 2007
@@ -72,7 +72,10 @@
             if (parts.length != 4) {
                 throw new IllegalArgumentException("Invalid id: " + key);
             }
-            Artifact source = new Artifact(parts[0], parts[1], (String) null, parts[3]);
+            if ("".equals(parts[2])) {
+                parts[2] = null;
+            }
+            Artifact source = new Artifact(parts[0], parts[1], parts[2], parts[3]);
             Artifact resolved = Artifact.create(resolvedString);
             explicitResolution.put(source, resolved);
         }



Mime
View raw message