* Remove org.apache.felix.sigil.common.core from org.apache.felix.sigil.ivy.resolver .classpath file
* Refactor resolver code to avoid need to import internal classes
(FELIX-1663)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@820254 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/ivy/resolver/.classpath b/sigil/ivy/resolver/.classpath
index df01fbf..c9ffd60 100644
--- a/sigil/ivy/resolver/.classpath
+++ b/sigil/ivy/resolver/.classpath
@@ -2,7 +2,6 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/org.apache.felix.sigil.common.core"/>
 	<classpathentry kind="con" path="org.apache.felix.sigil.classpathContainer"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
index ead0f73..7411ad1 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
@@ -25,15 +25,16 @@
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.config.BldFactory;
 import org.apache.felix.sigil.config.IBldProject;
 import org.apache.felix.sigil.config.IBldProject.IBldBundle;
-import org.apache.felix.sigil.core.internal.model.eclipse.SigilBundle;
-import org.apache.felix.sigil.core.internal.model.osgi.BundleModelElement;
 import org.apache.felix.sigil.core.licence.ILicensePolicy;
+import org.apache.felix.sigil.model.ModelElementFactory;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.model.osgi.IPackageExport;
@@ -41,8 +42,8 @@
 import org.apache.felix.sigil.model.osgi.IRequiredBundle;
 import org.apache.felix.sigil.repository.AbstractBundleRepository;
 import org.apache.felix.sigil.repository.IRepositoryVisitor;
+import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
-import org.apache.ivy.core.module.id.ModuleRevisionId;
 
 import org.osgi.framework.Version;
 
@@ -246,7 +247,7 @@
 
         for (IBldBundle bb : project.getBundles())
         {
-            IBundleModelElement info = new BundleModelElement();
+            IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(IBundleModelElement.class);
 
             for (IPackageExport pexport : bb.getExports())
             {
@@ -272,77 +273,27 @@
             Version version = new Version(bb.getVersion());
             info.setVersion(version);
 
-            ProjectBundle pb = new ProjectBundle();
+            ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
             pb.setBundleInfo(info);
-            pb.setId(bb.getId());
-
+            
+            Map<Object, Object> meta = new HashMap<Object, Object>();
             ModuleDescriptor md = SigilParser.instance().parseDescriptor(uri.toURL());
+            if ( !bb.getId().equals( md.getModuleRevisionId().getName() ) )
+            { // non-default artifact
+                for ( Artifact a : md.getAllArtifacts() ) {
+                    if ( a.getName().equals( bb.getId() ) ) {
+                        meta.put(Artifact.class, a);
+                        break;
+                    }
+                }
+            }
 
-            ModuleRevisionId mrid = md.getModuleRevisionId();
-            pb.setModule(mrid.getName());
-            pb.setOrg(mrid.getOrganisation());
-            // XXX: should revision be configurable?
-            pb.setRevision("latest." + md.getStatus());
-
+            meta.put(ModuleDescriptor.class, md);
+            pb.setMeta(meta);
+            
             list.add(pb);
             Log.debug("ProjectRepository: added " + pb);
             Log.debug("ProjectRepository: exports " + bb.getExports());
         }
     }
-
-    public static class ProjectBundle extends SigilBundle
-    {
-        private String id;
-        private String module;
-        private String org;
-        private String revision;
-
-        @Override
-        public String toString()
-        {
-            return "ProjectBundle[" + org + "@" + module + (id == null ? "" : "$" + id)
-                + "#" + revision + "]";
-        }
-
-        public String getModule()
-        {
-            return module;
-        }
-
-        public void setModule(String module)
-        {
-            this.module = module;
-        }
-
-        public String getId()
-        {
-            return id;
-        }
-
-        public void setId(String id)
-        {
-            this.id = id;
-        }
-
-        public String getRevision()
-        {
-            return revision;
-        }
-
-        public void setRevision(String rev)
-        {
-            this.revision = rev;
-        }
-
-        public String getOrg()
-        {
-            return org;
-        }
-
-        public void setOrg(String org)
-        {
-            this.org = org;
-        }
-    }
-
 }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
index 1bb30b9..a215202 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
@@ -537,23 +537,24 @@
                     continue;
                 }
 
-                if ( bundle instanceof ProjectRepository.ProjectBundle )
+                ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(ModuleDescriptor.class);
+                if ( bmd != null )
                 {
-                    ProjectRepository.ProjectBundle pb = ( ProjectRepository.ProjectBundle ) bundle;
-                    String org = pb.getOrg();
+                    ModuleRevisionId bmrid = bmd.getModuleRevisionId();
+                    String org = bmrid.getOrganisation();
                     if ( org == null )
                         org = masterMrid.getOrganisation();
-                    String id = pb.getId();
-                    String module = pb.getModule();
-                    String rev = pb.getRevision();
+                    String module = bmrid.getName();
+                    String rev = "latest." + bmd.getStatus();
 
                     mrid = ModuleRevisionId.newInstance( org, module, rev );
+                    
                     dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
 
-                    if ( !id.equals( module ) )
-                    { // non-default artifact
-                        dd.addDependencyArtifact( module, new DefaultDependencyArtifactDescriptor( dd, id, "jar",
-                            "jar", null, null ) );
+                    Artifact artifact = (Artifact) bundle.getMeta().get(Artifact.class);
+                    if ( artifact != null ) {
+                        dd.addDependencyArtifact( mrid.getName(), new DefaultDependencyArtifactDescriptor( dd, artifact.getName(), "jar",
+                            "jar", null, null ) );                        
                     }
                 }
                 else
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
index 5daad06..dc5c099 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
@@ -39,10 +39,11 @@
 
 import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.config.BldFactory;
-import org.apache.felix.sigil.core.internal.model.osgi.RequiredBundle;
 import org.apache.felix.sigil.model.IModelElement;
+import org.apache.felix.sigil.model.ModelElementFactory;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.model.osgi.IBundleModelElement;
+import org.apache.felix.sigil.model.osgi.IRequiredBundle;
 import org.apache.felix.sigil.repository.IResolution;
 import org.apache.felix.sigil.repository.ResolutionException;
 import org.apache.ivy.core.module.descriptor.Artifact;
@@ -247,7 +248,7 @@
             range = "[" + revision + "," + revision + "]";
         }
 
-        RequiredBundle bundle = new RequiredBundle();
+        IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
         bundle.setSymbolicName( id.getName() );
         bundle.setVersions( VersionRange.parseVersionRange( range ) );