You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/09/19 19:30:33 UTC

svn commit: r447920 - in /geronimo/server/trunk: maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/ modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ modules/geronimo-system/src/main/java/org/apache/...

Author: djencks
Date: Tue Sep 19 10:30:32 2006
New Revision: 447920

URL: http://svn.apache.org/viewvc?view=rev&rev=447920
Log:
GERONIMO-2409 Provide aliasing for configurations. Works surprisingly well: I expected something similar would be needed for Configuration and Kernel gbean lookups

Modified:
    geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/resolver/ExplicitDefaultArtifactResolver.java

Modified: geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java?view=diff&rev=447920&r1=447919&r2=447920
==============================================================================
--- geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java (original)
+++ geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/plugin/car/AbstractCarMojo.java Tue Sep 19 10:30:32 2006
@@ -184,7 +184,7 @@
         while (iter.hasNext()) {
             Artifact artifact = (Artifact)iter.next();
             String name = artifact.getGroupId() + "/" + artifact.getArtifactId() + "//" + artifact.getType();
-            String value = artifact.getVersion();
+            String value = artifact.getGroupId() + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + artifact.getType();
 
             log.debug("Setting " + name + "=" + value);
             props.setProperty(name, value);

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java?view=diff&rev=447920&r1=447919&r2=447920
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java (original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java Tue Sep 19 10:30:32 2006
@@ -51,6 +51,10 @@
 
     public Artifact generateArtifact(Artifact source, String defaultType) {
         if(source.isResolved()) {
+            Artifact deAliased = (Artifact) explicitResolution.get(source);
+            if (deAliased !=  null) {
+                return deAliased;
+            }
             return source;
         }
         String groupId = source.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID : source.getGroupId();
@@ -123,6 +127,11 @@
     }
 
     private Artifact resolveVersion(Collection parentConfigurations, Artifact working) {
+        //see if there is an explicit resolution for this artifact.
+        Artifact deAliased = (Artifact) explicitResolution.get(working);
+        if (deAliased != null) {
+            working = deAliased;
+        }
         SortedSet existingArtifacts;
         if (artifactManager != null) {
             existingArtifacts = artifactManager.getLoadedArtifacts(working);
@@ -133,18 +142,6 @@
         // if we have exactly one artifact loaded use its' version
         if (existingArtifacts.size() == 1) {
             return (Artifact) existingArtifacts.first();
-        }
-
-        //see if there is an explicit resolution for this artifact.
-        Artifact resolved = (Artifact) explicitResolution.get(working);
-        if (resolved != null) {
-            return resolved;
-        }
-        //see if there is an entry for the whole groupId.
-        Artifact groupId = new Artifact(working.getGroupId(), "", (Version)null, "");
-        resolved = (Artifact) explicitResolution.get(groupId);
-        if (resolved != null) {
-            return new Artifact(working.getGroupId(), working.getArtifactId(), resolved.getVersion(), working.getType());
         }
 
 

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=447920&r1=447919&r2=447920
==============================================================================
--- 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 Tue Sep 19 10:30:32 2006
@@ -32,7 +32,6 @@
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
@@ -68,14 +67,14 @@
         for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) {
             Map.Entry entry = (Map.Entry) iterator.next();
             String key = (String) entry.getKey();
-            String version = (String) entry.getValue();
+            String resolvedString = (String) entry.getValue();
             //split the string ourselves since we wish to allow blank artifactIds.
             String[] parts = key.split("/", -1);
             if (parts.length != 4) {
                 throw new IllegalArgumentException("Invalid id: " + key);
             }
             Artifact source = new Artifact(parts[0], parts[1], (String)null, parts[3]);
-            Artifact resolved = new Artifact(source.getGroupId(), source.getArtifactId(), version, source.getType());
+            Artifact resolved = Artifact.create(resolvedString);
             explicitResolution.put(source,resolved);
         }
         return explicitResolution;
@@ -88,7 +87,7 @@
         infoFactory.addAttribute("versionMapLocation", String.class, true, true);
         infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
         infoFactory.addReference("Repositories", ListableRepository.class, "Repository");
-        infoFactory.addReference("ServerInfo", ServerInfo.class, "ServerInfo");
+        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
         infoFactory.addInterface(ArtifactResolver.class);
 
         infoFactory.setConstructor(new String[]{