ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1056016 [1/2] - in /ant/ivy/core/trunk: src/java/org/apache/ivy/core/module/descriptor/ src/java/org/apache/ivy/osgi/core/ src/java/org/apache/ivy/osgi/obr/ src/java/org/apache/ivy/osgi/obr/xml/ src/java/org/apache/ivy/osgi/repo/ src/java/...
Date Thu, 06 Jan 2011 19:18:41 GMT
Author: hibou
Date: Thu Jan  6 19:18:41 2011
New Revision: 1056016

URL: http://svn.apache.org/viewvc?rev=1056016&view=rev
Log:
Try to make the code more generic about handling descriptor based repository

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java
      - copied, changed from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ExecutionEnvironmentProfile.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java
      - copied, changed from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java
      - copied, changed from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java
      - copied, changed from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoResolver.java
Removed:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ExecutionEnvironmentProfile.java
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileProvider.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileLoaderTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java
    ant/ivy/core/trunk/test/test-repo/ivyrepo/repo.xml

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Thu Jan  6 19:18:41 2011
@@ -65,9 +65,9 @@ public class DefaultModuleDescriptor imp
 
     public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, String[] confs,
             boolean transitive, boolean changing) {
-        DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
-                .newInstance(mrid.getOrganisation(), mrid.getName() + "-caller", "working"),
-                "integration", null, true);
+        DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
+                ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName() + "-caller",
+                    "working"), "integration", null, true);
         for (int i = 0; i < confs.length; i++) {
             moduleDescriptor.addConfiguration(new Configuration(confs[i]));
         }
@@ -84,8 +84,9 @@ public class DefaultModuleDescriptor imp
 
     public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid,
             boolean transitive, boolean changing) {
-        DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
-                .newInstance("caller", "all-caller", "working"), "integration", null, true);
+        DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
+                ModuleRevisionId.newInstance("caller", "all-caller", "working"), "integration",
+                null, true);
         moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
         moduleDescriptor.setLastModified(System.currentTimeMillis());
         for (int i = 0; i < mrid.length; i++) {
@@ -105,9 +106,10 @@ public class DefaultModuleDescriptor imp
         moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
         if (artifacts != null && artifacts.length > 0) {
             for (int i = 0; i < artifacts.length; i++) {
-                moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(
-                        moduleDescriptor, artifacts[i].getName(), artifacts[i].getType(),
-                        artifacts[i].getExt(), artifacts[i].getUrl(), artifacts[i].getExtraAttributes()));
+                moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
+                    new MDArtifact(moduleDescriptor, artifacts[i].getName(),
+                            artifacts[i].getType(), artifacts[i].getExt(), artifacts[i].getUrl(),
+                            artifacts[i].getExtraAttributes()));
             }
         } else {
             moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor,
@@ -122,8 +124,8 @@ public class DefaultModuleDescriptor imp
         DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release",
                 publicationDate, false);
         moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
-        moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid
-                .getName(), "jar", "jar"));
+        moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
+            new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
         return moduleDescriptor;
     }
 
@@ -153,8 +155,8 @@ public class DefaultModuleDescriptor imp
         for (int i = 0; i < ed.length; ++i) {
             ModuleRevisionId mrid = t.transform(ed[i].getParentRevisionId());
             ModuleRevisionId resolvedMrid = t.transform(ed[i].getResolvedParentRevisionId());
-            nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(mrid, resolvedMrid,
-                    ed[i].getLocation(), ed[i].getExtendsTypes()));
+            nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(mrid, resolvedMrid, ed[i]
+                    .getLocation(), ed[i].getExtendsTypes()));
         }
 
         DependencyDescriptor[] dd = md.getDependencies();
@@ -173,12 +175,12 @@ public class DefaultModuleDescriptor imp
         if (md instanceof DefaultModuleDescriptor) {
             DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
             nmd.conflictManagers = (ModuleRules) dmd.conflictManagers.clone();
-            nmd.dependencyDescriptorMediators = 
-                (ModuleRules) dmd.dependencyDescriptorMediators.clone();
+            nmd.dependencyDescriptorMediators = (ModuleRules) dmd.dependencyDescriptorMediators
+                    .clone();
         } else {
-            Message.warn(
-                "transformed module descriptor is not a default module descriptor: "
-                + "impossible to copy conflict manager and version mediation configuration: " + md);
+            Message.warn("transformed module descriptor is not a default module descriptor: "
+                    + "impossible to copy conflict manager and version mediation configuration: "
+                    + md);
         }
         nmd.licenses.addAll(Arrays.asList(md.getLicenses()));
         nmd.homePage = md.getHomePage();
@@ -207,15 +209,16 @@ public class DefaultModuleDescriptor imp
 
     private Map artifactsByConf = new HashMap(); // Map (String conf -> Collection(Artifact))
 
-    private Collection artifacts = new LinkedHashSet(); // Collection(Artifact) 
+    private Collection artifacts = new LinkedHashSet(); // Collection(Artifact)
+
     // all artifacts could also be found in the artifactsByConf map, but here we can
     // preserve the order
 
     private boolean isDefault = false;
 
-    private ModuleRules conflictManagers = new ModuleRules(); 
-    
-    private ModuleRules dependencyDescriptorMediators = new ModuleRules(); 
+    private ModuleRules conflictManagers = new ModuleRules();
+
+    private ModuleRules dependencyDescriptorMediators = new ModuleRules();
 
     private List licenses = new ArrayList(); // List(License)
 
@@ -232,16 +235,16 @@ public class DefaultModuleDescriptor imp
     private ModuleDescriptorParser parser;
 
     private Resource resource;
-    
+
     private List excludeRules = new ArrayList(); // List(ExcludeRule)
 
     private Artifact metadataArtifact;
 
-    private List inheritedDescriptors = new ArrayList(); //List(ExtendsDescriptor)
-    
-    private Map/*<String,String>*/ extraAttributesNamespaces = new LinkedHashMap();
+    private List inheritedDescriptors = new ArrayList(); // List(ExtendsDescriptor)
 
-    private Map/*<String,String>*/ extraInfo = new HashMap();
+    private Map/* <String,String> */extraAttributesNamespaces = new LinkedHashMap();
+
+    private Map/* <String,String> */extraInfo = new HashMap();
 
     public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
         this(id, status, pubDate, false);
@@ -272,15 +275,15 @@ public class DefaultModuleDescriptor imp
         this.parser = parser;
         resource = res;
     }
-    
+
     public Artifact getMetadataArtifact() {
         if (metadataArtifact == null) {
-            metadataArtifact = DefaultArtifact.newIvyArtifact(
-                resolvedRevId, resolvedPublicationDate);
+            metadataArtifact = DefaultArtifact.newIvyArtifact(resolvedRevId,
+                resolvedPublicationDate);
         }
         return metadataArtifact;
     }
-    
+
     public void setModuleArtifact(Artifact moduleArtifact) {
         this.metadataArtifact = moduleArtifact;
     }
@@ -310,7 +313,7 @@ public class DefaultModuleDescriptor imp
     public Date getResolvedPublicationDate() {
         return resolvedPublicationDate;
     }
-    
+
     public String getRevision() {
         return getResolvedModuleRevisionId().getRevision();
     }
@@ -355,8 +358,9 @@ public class DefaultModuleDescriptor imp
     public void addArtifact(String conf, Artifact artifact) {
         Configuration c = getConfiguration(conf);
         if (c == null) {
-            throw new IllegalArgumentException("Cannot add artifact '" + artifact.getId().getArtifactId().getShortDescription()
-                    + "' to configuration '" + conf + "' of module " + revId 
+            throw new IllegalArgumentException("Cannot add artifact '"
+                    + artifact.getId().getArtifactId().getShortDescription()
+                    + "' to configuration '" + conf + "' of module " + revId
                     + " because this configuration doesn't exist!");
         }
         if (c instanceof ConfigurationGroup) {
@@ -389,8 +393,8 @@ public class DefaultModuleDescriptor imp
     }
 
     public ExtendsDescriptor[] getInheritedDescriptors() {
-        return (ExtendsDescriptor[]) inheritedDescriptors.toArray(
-                new ExtendsDescriptor[inheritedDescriptors.size()]);
+        return (ExtendsDescriptor[]) inheritedDescriptors
+                .toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
     }
 
     public Configuration[] getConfigurations() {
@@ -427,7 +431,7 @@ public class DefaultModuleDescriptor imp
                 String attValue = m.group(2);
 
                 // this is a conf group, let's search for its members
-                Map /*<String,Configuration>*/ members = new LinkedHashMap();
+                Map /* <String,Configuration> */members = new LinkedHashMap();
                 for (Iterator it = configurations.values().iterator(); it.hasNext();) {
                     Configuration conf = (Configuration) it.next();
                     if (attValue.equals(conf.getAttribute(attName))) {
@@ -436,19 +440,18 @@ public class DefaultModuleDescriptor imp
                 }
                 return new ConfigurationGroup(confName, members);
             }
-            
+
             // let's see if a configuration intersection is requested
             String[] confs = confName.split("\\+");
             if (confs.length <= 1) {
                 return null;
             }
-            Map /*<String,Configuration>*/ intersectedConfs = new LinkedHashMap();
+            Map /* <String,Configuration> */intersectedConfs = new LinkedHashMap();
             for (int i = 0; i < confs.length; i++) {
                 Configuration c = (Configuration) configurations.get(confs[i]);
                 if (c == null) {
-                    Message.verbose(
-                        "missing configuration '" + confs[i] 
-                        + "' from intersection " + confName + " in " + this);
+                    Message.verbose("missing configuration '" + confs[i] + "' from intersection "
+                            + confName + " in " + this);
                     return null;
                 }
                 intersectedConfs.put(confs[i], c);
@@ -467,7 +470,7 @@ public class DefaultModuleDescriptor imp
         if (c instanceof ConfigurationIntersection) {
             ConfigurationIntersection intersection = (ConfigurationIntersection) c;
             String[] intersected = intersection.getIntersectedConfigurationNames();
-            Set/*<Artifact>*/ intersectedArtifacts = new LinkedHashSet();
+            Set/* <Artifact> */intersectedArtifacts = new LinkedHashSet();
             for (int j = 0; j < intersected.length; j++) {
                 Collection arts = getArtifactsIncludingExtending(intersected[j]);
                 if (intersectedArtifacts.isEmpty()) {
@@ -479,12 +482,12 @@ public class DefaultModuleDescriptor imp
             if (artifacts != null) {
                 intersectedArtifacts.addAll(artifacts);
             }
-            return (Artifact[]) intersectedArtifacts.toArray(
-                new Artifact[intersectedArtifacts.size()]);
+            return (Artifact[]) intersectedArtifacts.toArray(new Artifact[intersectedArtifacts
+                    .size()]);
         } else if (c instanceof ConfigurationGroup) {
             ConfigurationGroup group = (ConfigurationGroup) c;
             String[] members = group.getMembersConfigurationNames();
-            Set/*<Artifact>*/ groupArtifacts = new LinkedHashSet();
+            Set/* <Artifact> */groupArtifacts = new LinkedHashSet();
             for (int i = 0; i < members.length; i++) {
                 groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
             }
@@ -501,10 +504,10 @@ public class DefaultModuleDescriptor imp
         }
     }
 
-    private Collection/*<Artifact>*/ getArtifactsIncludingExtending(String conf) {
-        Collection extendingConfs = Configuration.findConfigurationExtending(
-                                                            conf, getConfigurations());
-        Set/*<Artifact>*/ artifacts = new LinkedHashSet();
+    private Collection/* <Artifact> */getArtifactsIncludingExtending(String conf) {
+        Collection extendingConfs = Configuration.findConfigurationExtending(conf,
+            getConfigurations());
+        Set/* <Artifact> */artifacts = new LinkedHashSet();
         Collection arts = (Collection) artifactsByConf.get(conf);
         if (arts != null) {
             artifacts.addAll(arts);
@@ -524,8 +527,8 @@ public class DefaultModuleDescriptor imp
     }
 
     public DependencyDescriptor[] getDependencies() {
-        return (DependencyDescriptor[]) dependencies
-                .toArray(new DependencyDescriptor[dependencies.size()]);
+        return (DependencyDescriptor[]) dependencies.toArray(new DependencyDescriptor[dependencies
+                .size()]);
     }
 
     public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
@@ -550,6 +553,34 @@ public class DefaultModuleDescriptor imp
         }
     }
 
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((revId == null) ? 0 : revId.hashCode());
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        DefaultModuleDescriptor other = (DefaultModuleDescriptor) obj;
+        if (revId == null) {
+            if (other.revId != null) {
+                return false;
+            }
+        } else if (!revId.equals(other.revId)) {
+            return false;
+        }
+        return true;
+    }
+
     public String toString() {
         return "module: " + revId + " status=" + status + " publication=" + publicationDate
                 + " configurations=" + configurations + " artifacts=" + artifactsByConf
@@ -576,13 +607,13 @@ public class DefaultModuleDescriptor imp
     public ConflictManager getConflictManager(ModuleId moduleId) {
         return (ConflictManager) conflictManagers.getRule(moduleId);
     }
-    
+
     public void addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher,
             DependencyDescriptorMediator ddm) {
-        dependencyDescriptorMediators.defineRule(
-            new MapMatcher(moduleId.getAttributes(), matcher), ddm);
+        dependencyDescriptorMediators.defineRule(new MapMatcher(moduleId.getAttributes(), matcher),
+            ddm);
     }
-    
+
     public DependencyDescriptor mediate(DependencyDescriptor dd) {
         Object[] mediators = dependencyDescriptorMediators.getRules(dd.getDependencyId());
         for (int i = 0; i < mediators.length; i++) {
@@ -591,7 +622,7 @@ public class DefaultModuleDescriptor imp
         return dd;
     }
 
-    public ModuleRules/*<DependencyDescriptorMediator>*/ getAllDependencyDescriptorMediators() {
+    public ModuleRules/* <DependencyDescriptorMediator> */getAllDependencyDescriptorMediators() {
         return (ModuleRules) dependencyDescriptorMediators.clone();
     }
 
@@ -610,11 +641,11 @@ public class DefaultModuleDescriptor imp
     public void setHomePage(String homePage) {
         this.homePage = homePage;
     }
-    
+
     public String getDescription() {
         return description;
     }
-    
+
     public void setDescription(String description) {
         this.description = description;
     }
@@ -646,8 +677,8 @@ public class DefaultModuleDescriptor imp
     }
 
     /**
-     * Throws an exception if the module descriptor is inconsistent 
-     * For the moment, only extended configurations existence and cycles are checked
+     * Throws an exception if the module descriptor is inconsistent For the moment, only extended
+     * configurations existence and cycles are checked
      */
     public void check() {
         Stack confs = new Stack();
@@ -670,8 +701,8 @@ public class DefaultModuleDescriptor imp
                 cycle.append(confs.get(index)).append(" => ");
             }
             cycle.append(confName);
-            throw new IllegalStateException(
-                "illegal cycle detected in configuration extension: " + cycle);
+            throw new IllegalStateException("illegal cycle detected in configuration extension: "
+                    + cycle);
         }
         Configuration conf = getConfiguration(confName);
         if (conf == null) {
@@ -714,8 +745,6 @@ public class DefaultModuleDescriptor imp
         return resolvedRevId.getQualifiedExtraAttributes();
     }
 
-
-
     public ModuleDescriptorParser getParser() {
         return parser;
     }
@@ -738,8 +767,8 @@ public class DefaultModuleDescriptor imp
      */
     public boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId) {
         if (namespace != null) {
-            artifactId = NameSpaceHelper.transform(artifactId, namespace
-                    .getFromSystemTransformer());
+            artifactId = NameSpaceHelper
+                    .transform(artifactId, namespace.getFromSystemTransformer());
         }
         ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
         for (int i = 0; i < rules.length; i++) {
@@ -769,7 +798,7 @@ public class DefaultModuleDescriptor imp
     private boolean containsAny(String[] arr1, String[] arr2) {
         return new ArrayList(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
     }
-    
+
     public Map getExtraAttributesNamespaces() {
         return extraAttributesNamespaces;
     }
@@ -778,12 +807,10 @@ public class DefaultModuleDescriptor imp
         extraAttributesNamespaces.put(prefix, namespace);
     }
 
-   
-    
     public void addExtraInfo(String infoKey, String value) {
         extraInfo.put(infoKey, value);
     }
-    
+
     public Map getExtraInfo() {
         return extraInfo;
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java Thu Jan  6 19:18:41 2011
@@ -37,7 +37,6 @@ import org.apache.ivy.core.module.descri
 import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.osgi.repo.ExecutionEnvironmentProfile;
 import org.apache.ivy.osgi.util.Version;
 import org.apache.ivy.osgi.util.VersionRange;
 import org.apache.ivy.plugins.matcher.ExactOrRegexpPatternMatcher;
@@ -197,7 +196,7 @@ public class BundleInfoAdapter {
         return builder.toString();
     }
 
-    private static DefaultArtifact decodeIvyLocation(String uri) {
+    private static DefaultArtifact decodeIvyLocation(final String uri) {
         String org = null;
         String name = null;
         String branch = null;
@@ -206,24 +205,27 @@ public class BundleInfoAdapter {
         String type = null;
         String ext = null;
 
-        uri = uri.substring(6);
-        int i = uri.indexOf('/');
+        String u = uri.substring(6);
+        int i = u.indexOf('/');
         if (i < 0) {
             throw new IllegalArgumentException("Expecting an organisation in the ivy uri: " + uri);
         }
-        org = uri.substring(0, i);
-        uri = uri.substring(i + 1);
+        org = u.substring(0, i);
+        u = u.substring(i + 1);
 
-        i = uri.indexOf('?');
+        i = u.indexOf('?');
         if (i < 0) {
             throw new IllegalArgumentException("Expecting an module name in the ivy uri: " + uri);
         }
-        name = uri.substring(0, i);
-        uri = uri.substring(i + 1);
+        name = u.substring(0, i);
+        u = u.substring(i + 1);
 
-        String[] parameters = uri.split("&");
+        String[] parameters = u.split("&");
         for (int j = 0; j < parameters.length; j++) {
             String parameter = parameters[j];
+            if (parameter.length() == 0) {
+                continue;
+            }
             String[] nameAndValue = parameter.split("=");
             if (nameAndValue.length != 2) {
                 throw new IllegalArgumentException("Malformed query string in the ivy uri: " + uri);

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java (from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ExecutionEnvironmentProfile.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ExecutionEnvironmentProfile.java&r1=1056009&r2=1056016&rev=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ExecutionEnvironmentProfile.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfile.java Thu Jan  6 19:18:41 2011
@@ -15,7 +15,7 @@
  *  limitations under the License.
  *
  */
-package org.apache.ivy.osgi.repo;
+package org.apache.ivy.osgi.core;
 
 import java.util.Set;
 import java.util.TreeSet;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileProvider.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileProvider.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileProvider.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ExecutionEnvironmentProfileProvider.java Thu Jan  6 19:18:41 2011
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
 
-import org.apache.ivy.osgi.repo.ExecutionEnvironmentProfile;
 import org.apache.ivy.util.Message;
 
 public class ExecutionEnvironmentProfileProvider {
@@ -37,6 +36,20 @@ public class ExecutionEnvironmentProfile
 
     private Map/* <String, ExecutionEnvironmentProfile> */profileList;
 
+    private static final ExecutionEnvironmentProfileProvider INSTANCE;
+
+    static {
+        try {
+            INSTANCE = new ExecutionEnvironmentProfileProvider();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static ExecutionEnvironmentProfileProvider getInstance() {
+        return INSTANCE;
+    }
+
     public ExecutionEnvironmentProfileProvider() throws IOException {
         profileList = loadDefaultProfileList();
     }
@@ -76,10 +89,10 @@ public class ExecutionEnvironmentProfile
     }
 
     private static ExecutionEnvironmentProfile loadProfile(Properties props, Map/*
-                                                                                * <String,
-                                                                                * ExecutionEnvironmentProfile
-                                                                                * >
-                                                                                */profiles,
+                                                                                 * <String,
+                                                                                 * ExecutionEnvironmentProfile
+                                                                                 * >
+                                                                                 */profiles,
             String name) {
 
         ExecutionEnvironmentProfile profile = new ExecutionEnvironmentProfile(name);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java Thu Jan  6 19:18:41 2011
@@ -32,8 +32,8 @@ import org.apache.ivy.core.module.descri
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
-import org.apache.ivy.osgi.repo.BundleRepoResolver;
 import org.apache.ivy.osgi.repo.RelativeURLRepository;
+import org.apache.ivy.osgi.repo.RepoDescriptorBasedResolver;
 import org.apache.ivy.plugins.repository.ArtifactResourceResolver;
 import org.apache.ivy.plugins.repository.Resource;
 import org.apache.ivy.plugins.repository.ResourceDownloader;
@@ -43,7 +43,7 @@ import org.apache.ivy.plugins.resolver.u
 import org.apache.ivy.util.FileUtil;
 import org.xml.sax.SAXException;
 
-public class OBRResolver extends BundleRepoResolver {
+public class OBRResolver extends RepoDescriptorBasedResolver {
 
     private String repoXmlURL;
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java Thu Jan  6 19:18:41 2011
@@ -24,8 +24,9 @@ import java.text.ParseException;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.ivy.osgi.core.BundleInfo;
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
 import org.apache.ivy.osgi.obr.filter.RequirementFilterParser;
-import org.apache.ivy.osgi.repo.BundleRepo;
+import org.apache.ivy.osgi.repo.BundleRepoDescriptor;
 import org.apache.ivy.osgi.util.DelegetingHandler;
 import org.apache.ivy.osgi.util.Version;
 import org.apache.ivy.util.Message;
@@ -82,7 +83,8 @@ public class OBRXMLParser {
 
     static final String FALSE = "false";
 
-    public static BundleRepo parse(InputStream in) throws ParseException, IOException, SAXException {
+    public static BundleRepoDescriptor parse(InputStream in) throws ParseException, IOException,
+            SAXException {
         RepositoryHandler handler = new RepositoryHandler();
         try {
             XMLHelper.parse(in, null, handler, null);
@@ -96,7 +98,7 @@ public class OBRXMLParser {
 
     private static class RepositoryHandler extends DelegetingHandler/* <DelegetingHandler<?>> */{
 
-        BundleRepo repo;
+        BundleRepoDescriptor repo;
 
         public RepositoryHandler() {
             super(REPOSITORY, null);
@@ -104,7 +106,7 @@ public class OBRXMLParser {
         }
 
         protected void handleAttributes(Attributes atts) {
-            repo = new BundleRepo();
+            repo = new BundleRepoDescriptor(ExecutionEnvironmentProfileProvider.getInstance());
 
             repo.setName(atts.getValue(REPOSITORY_NAME));
 

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java (from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java&r1=1056009&r2=1056016&rev=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java Thu Jan  6 19:18:41 2011
@@ -18,46 +18,26 @@
 package org.apache.ivy.osgi.repo;
 
 import java.text.ParseException;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
 
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.osgi.core.BundleCapability;
 import org.apache.ivy.osgi.core.BundleInfo;
+import org.apache.ivy.osgi.core.BundleInfoAdapter;
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
 import org.apache.ivy.osgi.core.ManifestParser;
-import org.apache.ivy.osgi.util.Version;
 import org.apache.ivy.util.Message;
 
-public class BundleRepo {
+public class BundleRepoDescriptor extends RepoDescriptor {
 
     private String name;
 
     private Long lastModified;
 
-    private final Set/* <BundleInfo> */bundles = new HashSet/* <BundleInfo> */();
+    private final ExecutionEnvironmentProfileProvider profileProvider;
 
-    private final Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */bundleByCapabilities = new HashMap/*
-                                                                                                                     * <
-                                                                                                                     * String
-                                                                                                                     * ,
-                                                                                                                     * Map
-                                                                                                                     * <
-                                                                                                                     * String
-                                                                                                                     * ,
-                                                                                                                     * Set
-                                                                                                                     * <
-                                                                                                                     * BundleCapabilityAndLocation
-                                                                                                                     * >>>
-                                                                                                                     */();
-
-    public BundleRepo() {
-        // default constructor
-    }
-
-    public BundleRepo(Iterator/* <ManifestAndLocation> */it) {
-        populate(it);
+    public BundleRepoDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
+        this.profileProvider = profileProvider;
     }
 
     public void setName(String name) {
@@ -92,72 +72,14 @@ public class BundleRepo {
     }
 
     public void addBundle(BundleInfo bundleInfo) {
-        bundles.add(bundleInfo);
-        populateCapabilities(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(),
-            bundleInfo.getVersion(), bundleInfo);
+        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo,
+            profileProvider);
+        add(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(), md);
         Iterator itCapability = bundleInfo.getCapabilities().iterator();
         while (itCapability.hasNext()) {
             BundleCapability capability = (BundleCapability) itCapability.next();
-            populateCapabilities(capability.getType(), capability.getName(),
-                capability.getVersion(), bundleInfo);
-        }
-    }
-
-    private void populateCapabilities(String type, String n, Version version, BundleInfo bundleInfo) {
-        Map/* <String, Set<BundleCapabilityAndLocation>> */map = (Map) bundleByCapabilities
-                .get(type);
-        if (map == null) {
-            map = new HashMap/* <String, Set<BundleCapabilityAndLocation>> */();
-            bundleByCapabilities.put(type, map);
-        }
-        Set/* <BundleCapabilityAndLocation> */bundleReferences = (Set) map.get(n);
-        if (bundleReferences == null) {
-            bundleReferences = new HashSet/* <BundleCapabilityAndLocation> */();
-            map.put(n, bundleReferences);
-        }
-        if (!bundleReferences.add(new BundleCapabilityAndLocation(type, n, version, bundleInfo))) {
-            Message.warn("The repo did already contains " + n + "#" + version);
-        }
-    }
-
-    public Set/* <BundleInfo> */getBundles() {
-        return bundles;
-    }
-
-    public Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */getBundleByCapabilities() {
-        return bundleByCapabilities;
-    }
-
-    public String toString() {
-        return bundles.toString();
-    }
-
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((bundles == null) ? 0 : bundles.hashCode());
-        return result;
-    }
-
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof BundleRepo)) {
-            return false;
-        }
-        BundleRepo other = (BundleRepo) obj;
-        if (bundles == null) {
-            if (other.bundles != null) {
-                return false;
-            }
-        } else if (!bundles.equals(other.bundles)) {
-            return false;
+            add(capability.getType(), capability.getName(), md);
         }
-        return true;
     }
 
 }

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java (from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java&r1=1056009&r2=1056016&rev=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java Thu Jan  6 19:18:41 2011
@@ -17,125 +17,67 @@
  */
 package org.apache.ivy.osgi.repo;
 
-import java.text.ParseException;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.ivy.osgi.core.BundleCapability;
-import org.apache.ivy.osgi.core.BundleInfo;
-import org.apache.ivy.osgi.core.ManifestParser;
-import org.apache.ivy.osgi.util.Version;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.util.Message;
 
-public class BundleRepo {
+public class RepoDescriptor {
 
-    private String name;
+    private final Map/* <String, Map<String, Set<ModuleDescriptor>>> */moduleByCapbilities = new HashMap();
 
-    private Long lastModified;
+    private final Set/* <ModuleDescriptor> */modules = new HashSet();
 
-    private final Set/* <BundleInfo> */bundles = new HashSet/* <BundleInfo> */();
-
-    private final Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */bundleByCapabilities = new HashMap/*
-                                                                                                                     * <
-                                                                                                                     * String
-                                                                                                                     * ,
-                                                                                                                     * Map
-                                                                                                                     * <
-                                                                                                                     * String
-                                                                                                                     * ,
-                                                                                                                     * Set
-                                                                                                                     * <
-                                                                                                                     * BundleCapabilityAndLocation
-                                                                                                                     * >>>
-                                                                                                                     */();
-
-    public BundleRepo() {
-        // default constructor
+    public Set getModules() {
+        return modules;
     }
 
-    public BundleRepo(Iterator/* <ManifestAndLocation> */it) {
-        populate(it);
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setLastModified(Long lastModified) {
-        this.lastModified = lastModified;
-    }
-
-    public Long getLastModified() {
-        return lastModified;
-    }
-
-    public void populate(Iterator/* <ManifestAndLocation> */it) {
-        while (it.hasNext()) {
-            ManifestAndLocation manifestAndLocation = (ManifestAndLocation) it.next();
-            try {
-                BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
-                        .getManifest());
-                bundleInfo.setUri(manifestAndLocation.getLocation());
-                addBundle(bundleInfo);
-            } catch (ParseException e) {
-                Message.error("Rejected " + manifestAndLocation.getLocation() + ": "
-                        + e.getMessage());
-            }
+    public Set/* <ModuleDescriptor> */findModule(String requirement, String value) {
+        Map/* <String, Set<ModuleDescriptor>> */modules = (Map) moduleByCapbilities
+                .get(requirement);
+        if (modules == null) {
+            return null;
         }
+        return (Set) modules.get(value);
     }
 
-    public void addBundle(BundleInfo bundleInfo) {
-        bundles.add(bundleInfo);
-        populateCapabilities(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(),
-            bundleInfo.getVersion(), bundleInfo);
-        Iterator itCapability = bundleInfo.getCapabilities().iterator();
-        while (itCapability.hasNext()) {
-            BundleCapability capability = (BundleCapability) itCapability.next();
-            populateCapabilities(capability.getType(), capability.getName(),
-                capability.getVersion(), bundleInfo);
+    public Set/* <String> */getCapabilityValues(String capabilityName) {
+        Map/* <String, Set<ModuleDescriptor>> */modules = (Map) moduleByCapbilities
+                .get(capabilityName);
+        if (modules == null) {
+            return null;
         }
+        return (Set) modules.keySet();
     }
 
-    private void populateCapabilities(String type, String n, Version version, BundleInfo bundleInfo) {
-        Map/* <String, Set<BundleCapabilityAndLocation>> */map = (Map) bundleByCapabilities
-                .get(type);
+    public void add(String type, String value, ModuleDescriptor md) {
+        modules.add(md);
+        Map/* <String, Set<ModuleDescriptor>> */map = (Map) moduleByCapbilities.get(type);
         if (map == null) {
-            map = new HashMap/* <String, Set<BundleCapabilityAndLocation>> */();
-            bundleByCapabilities.put(type, map);
+            map = new HashMap/* <String, Set<ModuleDescriptor>> */();
+            moduleByCapbilities.put(type, map);
         }
-        Set/* <BundleCapabilityAndLocation> */bundleReferences = (Set) map.get(n);
+        Set/* <ModuleDescriptor> */bundleReferences = (Set) map.get(value);
         if (bundleReferences == null) {
-            bundleReferences = new HashSet/* <BundleCapabilityAndLocation> */();
-            map.put(n, bundleReferences);
+            bundleReferences = new HashSet/* <ModuleDescriptor> */();
+            map.put(value, bundleReferences);
         }
-        if (!bundleReferences.add(new BundleCapabilityAndLocation(type, n, version, bundleInfo))) {
-            Message.warn("The repo did already contains " + n + "#" + version);
+        if (!bundleReferences.add(md)) {
+            Message.warn("The repo did already contains " + md);
         }
     }
 
-    public Set/* <BundleInfo> */getBundles() {
-        return bundles;
-    }
-
-    public Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */getBundleByCapabilities() {
-        return bundleByCapabilities;
-    }
-
     public String toString() {
-        return bundles.toString();
+        return modules.toString();
     }
 
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((bundles == null) ? 0 : bundles.hashCode());
+        result = prime * result + ((modules == null) ? 0 : modules.hashCode());
         return result;
     }
 
@@ -146,15 +88,15 @@ public class BundleRepo {
         if (obj == null) {
             return false;
         }
-        if (!(obj instanceof BundleRepo)) {
+        if (getClass() != obj.getClass()) {
             return false;
         }
-        BundleRepo other = (BundleRepo) obj;
-        if (bundles == null) {
-            if (other.bundles != null) {
+        RepoDescriptor other = (RepoDescriptor) obj;
+        if (modules == null) {
+            if (other.modules != null) {
                 return false;
             }
-        } else if (!bundles.equals(other.bundles)) {
+        } else if (!modules.equals(other.modules)) {
             return false;
         }
         return true;

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java (from r1056009, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoResolver.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoResolver.java&r1=1056009&r2=1056016&rev=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java Thu Jan  6 19:18:41 2011
@@ -19,7 +19,6 @@ package org.apache.ivy.osgi.repo;
 
 import java.io.File;
 import java.io.IOException;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -33,40 +32,34 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
-import org.apache.ivy.core.module.descriptor.MDArtifact;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
-import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 import org.apache.ivy.osgi.core.BundleInfo;
 import org.apache.ivy.osgi.core.BundleInfoAdapter;
 import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
-import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
 import org.apache.ivy.osgi.util.Version;
-import org.apache.ivy.plugins.conflict.ConflictManager;
-import org.apache.ivy.plugins.latest.ArtifactInfo;
 import org.apache.ivy.plugins.repository.Repository;
 import org.apache.ivy.plugins.repository.Resource;
-import org.apache.ivy.plugins.repository.file.FileRepository;
 import org.apache.ivy.plugins.resolver.BasicResolver;
+import org.apache.ivy.plugins.resolver.util.MDResolvedResource;
 import org.apache.ivy.plugins.resolver.util.ResolvedResource;
-import org.apache.ivy.plugins.version.VersionMatcher;
+import org.apache.ivy.plugins.resolver.util.ResourceMDParser;
 import org.apache.ivy.util.Message;
-import org.xml.sax.SAXException;
 
-public abstract class BundleRepoResolver extends BasicResolver {
+public abstract class RepoDescriptorBasedResolver extends BasicResolver {
 
     private Repository repository = null;
 
-    private BundleRepo repoDescriptor = null;
+    private RepoDescriptor repoDescriptor = null;
 
     private ExecutionEnvironmentProfileProvider profileProvider;
 
@@ -106,7 +99,7 @@ public abstract class BundleRepoResolver
         this.repository = repository;
     }
 
-    protected void setRepoDescriptor(BundleRepo repoDescriptor) {
+    protected void setRepoDescriptor(RepoDescriptor repoDescriptor) {
         this.repoDescriptor = repoDescriptor;
     }
 
@@ -123,173 +116,74 @@ public abstract class BundleRepoResolver
         return repository;
     }
 
-    private BundleRepo getRepoDescriptor() {
+    private RepoDescriptor getRepoDescriptor() {
         ensureInit();
         return repoDescriptor;
     }
 
-    public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
-            throws ParseException {
-        DefaultModuleDescriptor md = getDependencyMD(dd, data);
-        if (md == null) {
-            // not found, so let's return the mrid resolved by a previous resolver
-            return data.getCurrentResolvedModuleRevision();
-        }
-        Artifact mdar = new MDArtifact(md, "MANIFEST", "manifest", "MF");
-        MetadataArtifactDownloadReport mdardr = new MetadataArtifactDownloadReport(mdar);
-        mdardr.setDownloadStatus(DownloadStatus.SUCCESSFUL);
-        return new ResolvedModuleRevision(this, this, md, mdardr);
+    public boolean isCheckconsistency() {
+        // since a module can fit a requirement with a different id, no not check anything
+        return false;
     }
 
-    private DefaultModuleDescriptor getDependencyMD(DependencyDescriptor dd, ResolveData data) {
+    public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
         ModuleRevisionId mrid = dd.getDependencyRevisionId();
 
         String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
-        Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilities = (Map) getRepoDescriptor()
-                .getBundleByCapabilities().get(osgiAtt);
-        if (bundleCapabilities == null) {
-            Message.verbose("\t Not an OSGi dependency: " + mrid);
-            return null;
-        }
-
         String id = mrid.getName();
-        Set/* <BundleCapabilityAndLocation> */bundleReferences = (Set) bundleCapabilities.get(id);
-        if (bundleReferences == null || bundleReferences.isEmpty()) {
+        Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, id);
+        if (mds == null || mds.isEmpty()) {
             Message.verbose("\t " + id + " not found.");
             return null;
         }
 
-        List/* <BundleCandidate> */ret = new ArrayList/* <BundleCandidate> */();
-        Iterator itBundle = bundleReferences.iterator();
-        while (itBundle.hasNext()) {
-            BundleCapabilityAndLocation bundleCapability = (BundleCapabilityAndLocation) itBundle
-                    .next();
-            BundleInfo bundleInfo = bundleCapability.getBundleInfo();
-            if (!bundleCapability.getType().equals(BundleInfo.BUNDLE_TYPE)) {
-                ModuleRevisionId foundMrid = ModuleRevisionId.newInstance("",
-                    bundleInfo.getSymbolicName(), bundleInfo.getVersion().toString(),
-                    BundleInfoAdapter.OSGI_BUNDLE);
-                if (data.getVisitData(foundMrid) != null) {
+        ResolvedResource[] ret = new ResolvedResource[mds.size()];
+        int i = 0;
+        Iterator itMd = mds.iterator();
+        while (itMd.hasNext()) {
+            ModuleDescriptor md = (ModuleDescriptor) itMd.next();
+            MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
+            report.setDownloadStatus(DownloadStatus.NO);
+            report.setSearched(true);
+            ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report);
+            MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr);
+            if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
+                if (data.getVisitData(md.getModuleRevisionId()) != null) {
                     // already resolved import, no need to go further
-                    DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo,
-                        profileProvider);
-                    md.setPublicationDate(new Date(0));
-                    return md;
+                    return mdrr;
                 }
             }
-            BundleCandidate candidate = new BundleCandidate();
-            candidate.bundleInfo = bundleInfo;
-            candidate.version = bundleCapability.getVersion().toString();
-            ret.add(candidate);
+            ret[i++] = mdrr;
         }
 
-        DefaultModuleDescriptor found = selectResource(ret, mrid, data.getDate());
+        ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
+            data.getDate());
         if (found == null) {
             Message.debug("\t" + getName() + ": no resource found for " + mrid);
         }
         return found;
     }
 
-    private class BundleCandidate implements ArtifactInfo {
-
-        BundleInfo bundleInfo;
-
-        String version;
-
-        public long getLastModified() {
-            return 0;
-        }
-
-        public String getRevision() {
-            return version;
-        }
-
-    }
-
-    public DefaultModuleDescriptor selectResource(List/* <BundleCandidate> */rress,
+    public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
             ModuleRevisionId mrid, Date date) {
-        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
-
-        List/* <BundleCandidate> */founds = new ArrayList/* <BundleCandidate> */();
-        List/* <BundleCandidate> */sorted = getLatestStrategy().sort(
-            (ArtifactInfo[]) rress.toArray(new BundleCandidate[rress.size()]));
-        List/* <String> */rejected = new ArrayList/* <String> */();
-        List/* <ModuleRevisionId> */foundBlacklisted = new ArrayList/* <ModuleRevisionId> */();
-        IvyContext context = IvyContext.getContext();
-
-        Iterator itBundle = sorted.iterator();
-        while (itBundle.hasNext()) {
-            BundleCandidate rres = (BundleCandidate) itBundle.next();
-            if (filterNames(new ArrayList/* <String> */(Collections.singleton(rres.getRevision())))
-                    .isEmpty()) {
-                Message.debug("\t" + getName() + ": filtered by name: " + rres);
-                continue;
-            }
-            if ((date != null && rres.getLastModified() > date.getTime())) {
-                Message.verbose("\t" + getName() + ": too young: " + rres);
-                rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
-                continue;
-            }
-            ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
-
-            ResolveData data = context.getResolveData();
-            if (data != null && data.getReport() != null
-                    && data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
-                Message.debug("\t" + getName() + ": blacklisted: " + rres);
-                rejected.add(rres.getRevision() + " (blacklisted)");
-                foundBlacklisted.add(foundMrid);
-                continue;
-            }
-
-            if (!versionMatcher.accept(mrid, foundMrid)) {
-                Message.debug("\t" + getName() + ": rejected by version matcher: " + rres);
-                rejected.add(rres.getRevision());
-                continue;
-            }
-            if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
-                throw new IllegalStateException();
-            } else {
-                founds.add(rres);
-            }
-        }
-        if (founds.isEmpty() && !rejected.isEmpty()) {
-            logAttempt(rejected.toString());
-        }
-        if (founds.isEmpty() && !foundBlacklisted.isEmpty()) {
-            // all acceptable versions have been blacklisted, this means that an unsolvable conflict
-            // has been found
-            DependencyDescriptor dd = context.getDependencyDescriptor();
-            IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
-            ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
-            cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
-        }
-        if (founds.isEmpty()) {
-            return null;
-        }
-
-        BundleCandidate found = (BundleCandidate) founds.get(0);
+        ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
 
         String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
         // for non bundle requirement : log the selected bundle
         if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
             // several candidates with different symbolic name : make an warning about the ambiguity
-            if (founds.size() != 1) {
+            if (rress.length != 1) {
                 // several candidates with different symbolic name ?
-                Map/* <String, List<BundleCandidate>> */matching = new HashMap/*
-                                                                               * <String,
-                                                                               * List<BundleCandidate
-                                                                               * >>
-                                                                               */();
-                Iterator itBundle2 = founds.iterator();
-                while (itBundle2.hasNext()) {
-                    BundleCandidate c = (BundleCandidate) itBundle2.next();
-                    String name = c.bundleInfo.getSymbolicName();
-                    List/* <BundleCandidate> */list = (List) matching.get(name);
+                Map/* <String, List<MDResolvedResource>> */matching = new HashMap();
+                for (int i = 0; i < rress.length; i++) {
+                    String name = ((MDResolvedResource) rress[i]).getResolvedModuleRevision()
+                            .getId().getName();
+                    List/* <MDResolvedResource> */list = (List) matching.get(name);
                     if (list == null) {
-                        list = new ArrayList/* <BundleCandidate> */();
+                        list = new ArrayList/* <MDResolvedResource> */();
                         matching.put(name, list);
                     }
-                    list.add(c);
+                    list.add(rress[i]);
                 }
                 if (matching.keySet().size() != 1) {
                     if (requirementStrategy == RequirementStrategy.first) {
@@ -297,12 +191,12 @@ public abstract class BundleRepoResolver
                                 + mrid.getName() + ";version=" + mrid.getRevision());
                         Iterator itMatching = matching.entrySet().iterator();
                         while (itMatching.hasNext()) {
-                            Entry/* <String, List<BundleCandidate>> */entry = (Entry) itMatching
+                            Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
                                     .next();
                             Message.warn("\t" + entry.getKey());
                             Iterator itB = ((List) entry.getValue()).iterator();
                             while (itB.hasNext()) {
-                                BundleCandidate c = (BundleCandidate) itB.next();
+                                MDResolvedResource c = (MDResolvedResource) itB.next();
                                 Message.warn("\t\t" + c.getRevision()
                                         + (found == c ? " (selected)" : ""));
                             }
@@ -312,12 +206,12 @@ public abstract class BundleRepoResolver
                                 + mrid.getName() + ";version=" + mrid.getRevision());
                         Iterator itMatching = matching.entrySet().iterator();
                         while (itMatching.hasNext()) {
-                            Entry/* <String, List<BundleCandidate>> */entry = (Entry) itMatching
+                            Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
                                     .next();
                             Message.error("\t" + entry.getKey());
                             Iterator itB = ((List) entry.getValue()).iterator();
                             while (itB.hasNext()) {
-                                BundleCandidate c = (BundleCandidate) itB.next();
+                                MDResolvedResource c = (MDResolvedResource) itB.next();
                                 Message.error("\t\t" + c.getRevision()
                                         + (found == c ? " (best match)" : ""));
                             }
@@ -327,14 +221,12 @@ public abstract class BundleRepoResolver
                 }
             }
             Message.info("'" + osgiAtt + "' requirement " + mrid.getName() + ";version="
-                    + mrid.getRevision() + " satisfied by " + found.bundleInfo.getSymbolicName()
+                    + mrid.getRevision() + " satisfied by "
+                    + ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName()
                     + ";" + found.getRevision());
         }
 
-        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(found.bundleInfo,
-            profileProvider);
-        md.setPublicationDate(new Date(found.getLastModified()));
-        return md;
+        return found;
     }
 
     public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
@@ -361,9 +253,8 @@ public abstract class BundleRepoResolver
 
         String osgiAtt = (String) tokenValues.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
 
-        Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilityMap = (Map) getRepoDescriptor()
-                .getBundleByCapabilities().get(osgiAtt);
-        if (bundleCapabilityMap == null || bundleCapabilityMap.isEmpty()) {
+        Set/* <String> */capabilityValues = getRepoDescriptor().getCapabilityValues(osgiAtt);
+        if (capabilityValues == null || capabilityValues.isEmpty()) {
             return Collections.EMPTY_LIST;
         }
 
@@ -372,20 +263,18 @@ public abstract class BundleRepoResolver
         }
 
         if (IvyPatternHelper.MODULE_KEY.equals(token)) {
-            return bundleCapabilityMap.keySet();
+            return capabilityValues;
         }
 
         if (IvyPatternHelper.REVISION_KEY.equals(token)) {
             String name = (String) tokenValues.get(IvyPatternHelper.MODULE_KEY);
             List/* <String> */versions = new ArrayList/* <String> */();
-            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
-                    .get(name);
-            if (bundleCapabilities != null) {
-                Iterator itBundle = bundleCapabilities.iterator();
-                while (itBundle.hasNext()) {
-                    BundleCapabilityAndLocation bundleCapability = (BundleCapabilityAndLocation) itBundle
-                            .next();
-                    versions.add(bundleCapability.getVersion().toString());
+            Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, name);
+            if (mds != null) {
+                Iterator itMd = mds.iterator();
+                while (itMd.hasNext()) {
+                    ModuleDescriptor md = (ModuleDescriptor) itMd.next();
+                    versions.add(md.getRevision());
                 }
             }
             return versions;
@@ -399,8 +288,8 @@ public abstract class BundleRepoResolver
             if (osgiAtt.equals(BundleInfo.PACKAGE_TYPE)) {
                 return Collections.singletonList(BundleInfoAdapter.CONF_USE_PREFIX + name);
             }
-            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
-                    .get(name);
+            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
+                    .findModule(osgiAtt, name);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_LIST;
             }
@@ -474,9 +363,8 @@ public abstract class BundleRepoResolver
         }
         values.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, osgiAtt);
 
-        Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilityMap = (Map) getRepoDescriptor()
-                .getBundleByCapabilities().get(osgiAtt);
-        if (bundleCapabilityMap == null || bundleCapabilityMap.isEmpty()) {
+        Set/* <String> */capabilities = getRepoDescriptor().getCapabilityValues(osgiAtt);
+        if (capabilities == null || capabilities.isEmpty()) {
             return Collections.EMPTY_SET;
         }
 
@@ -490,9 +378,8 @@ public abstract class BundleRepoResolver
         tokenSet.remove(IvyPatternHelper.MODULE_KEY);
         String module = (String) criteria.get(IvyPatternHelper.MODULE_KEY);
         if (module == null) {
-            Set/* <String> */names = bundleCapabilityMap.keySet();
             Set/* <Map<String, String>> */tokenValues = new HashSet/* <Map<String, String>> */();
-            Iterator itNames = names.iterator();
+            Iterator itNames = capabilities.iterator();
             while (itNames.hasNext()) {
                 String name = (String) itNames.next();
                 Map/* <String, String> */newCriteria = new HashMap/* <String, String> */(criteria);
@@ -506,8 +393,8 @@ public abstract class BundleRepoResolver
         tokenSet.remove(IvyPatternHelper.REVISION_KEY);
         String rev = (String) criteria.get(IvyPatternHelper.REVISION_KEY);
         if (rev == null) {
-            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
-                    .get(module);
+            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
+                    .findModule(osgiAtt, module);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_SET;
             }
@@ -531,8 +418,8 @@ public abstract class BundleRepoResolver
                 values.put(IvyPatternHelper.CONF_KEY, BundleInfoAdapter.CONF_USE_PREFIX + module);
                 return Collections./* <Map<String, String>> */singleton(values);
             }
-            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
-                    .get(module);
+            Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
+                    .findModule(osgiAtt, module);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_SET;
             }
@@ -589,10 +476,4 @@ public abstract class BundleRepoResolver
         throw new UnsupportedOperationException();
     }
 
-    // useless methods that must not be called
-
-    public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
-        throw new UnsupportedOperationException();
-    }
-
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java?rev=1056016&r1=1056015&r2=1056016&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java Thu Jan  6 19:18:41 2011
@@ -114,100 +114,6 @@ public abstract class AbstractPatternsBa
     protected abstract ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid,
             String pattern, Artifact artifact, ResourceMDParser rmdparser, Date date);
 
-    public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
-            ModuleRevisionId mrid, Date date) {
-        String name = getName();
-        VersionMatcher versionMatcher = getSettings().getVersionMatcher();
-        
-        ResolvedResource found = null;
-        List sorted = getLatestStrategy().sort(rress);
-        List rejected = new ArrayList();
-        List foundBlacklisted = new ArrayList();
-        IvyContext context = IvyContext.getContext();
-        
-        for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
-            ResolvedResource rres = (ResolvedResource) iter.previous();
-            // we start by filtering based on information already available,
-            // even though we don't even know if the resource actually exist.
-            // But checking for existence is most of the time more costly than checking 
-            // name, blacklisting and first level version matching
-            if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
-                Message.debug("\t" + name + ": filtered by name: " + rres);
-                continue;
-            }
-            ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
-            
-            ResolveData data = context.getResolveData();
-            if (data != null
-                    && data.getReport() != null 
-                    && data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
-                Message.debug("\t" + name + ": blacklisted: " + rres);
-                rejected.add(rres.getRevision() + " (blacklisted)");
-                foundBlacklisted.add(foundMrid);
-                continue;
-            }
-            
-            if (!versionMatcher.accept(mrid, foundMrid)) {
-                Message.debug("\t" + name + ": rejected by version matcher: " + rres);
-                rejected.add(rres.getRevision());
-                continue;
-            }
-            if (!rres.getResource().exists()) {
-                Message.debug("\t" + name + ": unreachable: " + rres 
-                    + "; res=" + rres.getResource());
-                rejected.add(rres.getRevision() + " (unreachable)");
-                continue;
-            }
-            if ((date != null && rres.getLastModified() > date.getTime())) {
-                Message.verbose("\t" + name + ": too young: " + rres);
-                rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
-                continue;
-            }
-            if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
-                ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
-                if (r == null) {
-                    Message.debug("\t" + name 
-                        + ": impossible to get module descriptor resource: " + rres);
-                    rejected.add(rres.getRevision() + " (no or bad MD)");
-                    continue;
-                }
-                ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision()
-                        .getDescriptor();
-                if (md.isDefault()) {
-                    Message.debug("\t" + name + ": default md rejected by version matcher" 
-                            + "requiring module descriptor: " + rres);
-                    rejected.add(rres.getRevision() + " (MD)");
-                    continue;
-                } else if (!versionMatcher.accept(mrid, md)) {
-                    Message.debug("\t" + name + ": md rejected by version matcher: " + rres);
-                    rejected.add(rres.getRevision() + " (MD)");
-                    continue;
-                } else {
-                    found = r;
-                }
-            } else {
-                found = rres;
-            }
-
-            if (found != null) {
-                break;
-            }
-        }
-        if (found == null && !rejected.isEmpty()) {
-            logAttempt(rejected.toString());
-        }
-        if (found == null && !foundBlacklisted.isEmpty()) {
-            // all acceptable versions have been blacklisted, this means that an unsolvable conflict
-            // has been found
-            DependencyDescriptor dd = context.getDependencyDescriptor();
-            IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
-            ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
-            cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
-        }
-
-        return found;
-    }
-
     protected Collection findNames(Map tokenValues, String token) {
         Collection names = new HashSet();
         names.addAll(findIvyNames(tokenValues, token));
@@ -356,21 +262,6 @@ public abstract class AbstractPatternsBa
     
     protected abstract boolean exist(String path);
 
-    /**
-     * Filters names before returning them in the findXXXNames or findTokenValues method.
-     * <p>
-     * Remember to call the super implementation when overriding this method.
-     * </p>
-     * 
-     * @param names
-     *            the list to filter.
-     * @return the filtered list
-     */
-    protected Collection filterNames(Collection names) {
-        getSettings().filterIgnore(names);
-        return names;
-    }
-
     protected void findTokenValues(Collection names, List patterns, Map tokenValues, String token) {
         //to be overridden by subclasses wanting to have listing features
     }



Mime
View raw message