You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gc...@apache.org on 2010/09/02 18:19:18 UTC

svn commit: r992005 - in /incubator/aries/trunk/subsystem: subsystem-core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ subsystem-core/src/test/java/org/apache/...

Author: gcc
Date: Thu Sep  2 16:19:13 2010
New Revision: 992005

URL: http://svn.apache.org/viewvc?rev=992005&view=rev
Log:
ARIES-396
Changes to use org.apache.felix.bundlerepository instead of org.osgi.services.obr, the former being more current.

Modified:
    incubator/aries/trunk/subsystem/subsystem-core/pom.xml
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
    incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/MockRepositoryAdminImpl.java
    incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/ResourceResolverTest.java
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java

Modified: incubator/aries/trunk/subsystem/subsystem-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/pom.xml?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/pom.xml (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/pom.xml Thu Sep  2 16:19:13 2010
@@ -85,8 +85,8 @@
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
-            <artifactId>org.osgi.service.obr</artifactId>
-            <optional>true</optional>
+            <artifactId>org.apache.felix.bundlerepository</artifactId>
+            <version>1.6.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>junit</groupId>

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java Thu Sep  2 16:19:13 2010
@@ -78,7 +78,8 @@ public class BundleResourceProcessor imp
             } catch (SubsystemException e) {
                 throw e;
             } catch (Exception e) {
-                throw new SubsystemException("Unable to process bundle resource", e);
+//                throw new SubsystemException("Unable to process bundle resource", e);
+            	e.printStackTrace();
             }
         }
 

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java Thu Sep  2 16:19:13 2010
@@ -42,10 +42,11 @@ import org.apache.aries.subsystem.spi.Re
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
-import org.osgi.service.obr.Repository;
-import org.osgi.service.obr.RepositoryAdmin;
-import org.osgi.service.obr.Requirement;
-import org.osgi.service.obr.Resolver;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Reason;
+import org.apache.felix.bundlerepository.Resolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -163,11 +164,11 @@ public class ResourceResolverImpl implem
         filterString.append("(&(name" + "=" + symbolicName + "))");
         filterString.append("(version" + "=" + version + "))");
 
-        //org.osgi.service.obr.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
+        //org.apache.felix.bundlerepository.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
         Repository[] repos = this.repositoryAdmin.listRepositories();
-        org.osgi.service.obr.Resource res = null;
+        org.apache.felix.bundlerepository.Resource res = null;
         for (Repository repo : repos) {
-            org.osgi.service.obr.Resource[] resources = repo.getResources();
+            org.apache.felix.bundlerepository.Resource[] resources = repo.getResources();
             for (int i = 0; i < resources.length; i++) {
                 if (resources[i].getSymbolicName().equals(symbolicName)) {
                     if (resources[i].getVersion().compareTo(new Version(version)) == 0) {
@@ -185,22 +186,22 @@ public class ResourceResolverImpl implem
 
         Object type = props.get(SubsystemConstants.RESOURCE_TYPE_ATTRIBUTE);
 
-        return new ResourceImpl(symbolicName, res.getVersion(), type == null ? SubsystemConstants.RESOURCE_TYPE_BUNDLE : (String)type, res.getURL().toExternalForm() , props);
+        return new ResourceImpl(symbolicName, res.getVersion(), type == null ? SubsystemConstants.RESOURCE_TYPE_BUNDLE : (String)type, res.getURI() , props);
     }
     
     /**
      * the format of resource is like bundlesymbolicname;version=1.0.0, for example com.ibm.ws.eba.example.blog.api;version=1.0.0,
      */
-    private org.osgi.service.obr.Resource findOBRResource(Resource resource) throws SubsystemException {
+    private org.apache.felix.bundlerepository.Resource findOBRResource(Resource resource) throws SubsystemException {
         String symbolicName = resource.getSymbolicName();
         // this version could possibly be a range
         Version version = resource.getVersion();
 
-        //org.osgi.service.obr.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
+        //org.apache.felix.bundlerepository.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
         Repository[] repos = this.repositoryAdmin.listRepositories();
-        org.osgi.service.obr.Resource res = null;
+        org.apache.felix.bundlerepository.Resource res = null;
         for (Repository repo : repos) {
-            org.osgi.service.obr.Resource[] resources = repo.getResources();
+            org.apache.felix.bundlerepository.Resource[] resources = repo.getResources();
             for (int i = 0; i < resources.length; i++) {
                 if (resources[i].getSymbolicName().equals(symbolicName)) {
                     if (resources[i].getVersion().compareTo(version) == 0) {
@@ -215,7 +216,7 @@ public class ResourceResolverImpl implem
     /**
      * convert to the resource from the obr resource
      */
-    private Resource toResource(org.osgi.service.obr.Resource resource) throws SubsystemException {
+    private Resource toResource(org.apache.felix.bundlerepository.Resource resource) throws SubsystemException {
         if (resource == null) {
             throw new SubsystemException("unable to find the resource " + resource);
         }
@@ -225,7 +226,7 @@ public class ResourceResolverImpl implem
 
         Object type = props.get(SubsystemConstants.RESOURCE_TYPE_ATTRIBUTE);
 
-        return new ResourceImpl(resource.getSymbolicName(), resource.getVersion(), type == null ? SubsystemConstants.RESOURCE_TYPE_BUNDLE : (String)type, resource.getURL().toExternalForm() , props);
+        return new ResourceImpl(resource.getSymbolicName(), resource.getVersion(), type == null ? SubsystemConstants.RESOURCE_TYPE_BUNDLE : (String)type, resource.getURI() , props);
     }
     
     public List<Resource> resolve(List<Resource> subsystemContent,
@@ -238,33 +239,33 @@ public class ResourceResolverImpl implem
         
         // add subsystem content to the resolver
         for (Resource res : subsystemContent) {
-            org.osgi.service.obr.Resource obrRes = findOBRResource(res);
+            org.apache.felix.bundlerepository.Resource obrRes = findOBRResource(res);
             obrResolver.add(obrRes);
         }
         
         // add subsystem resource to the resolver
         for (Resource res : subsystemResources) {
-            org.osgi.service.obr.Resource obrRes = findOBRResource(res);
+            org.apache.felix.bundlerepository.Resource obrRes = findOBRResource(res);
             obrResolver.add(obrRes);
         }
         
         // Question: do we need to create the repository.xml for the subsystem and add the repo to RepoAdmin?
         List<Resource> resources = new ArrayList<Resource>();
         if (obrResolver.resolve()) {
-            for (org.osgi.service.obr.Resource res : obrResolver.getRequiredResources()) {
+            for (org.apache.felix.bundlerepository.Resource res : obrResolver.getRequiredResources()) {
                 resources.add(toResource(res));
             }
             
             // Question: should we handle optional resource differently?
-            for (org.osgi.service.obr.Resource res : obrResolver.getOptionalResources()) {
+            for (org.apache.felix.bundlerepository.Resource res : obrResolver.getOptionalResources()) {
                 resources.add(toResource(res));
             }
         } else {
             // log the unsatisfied requirement
-            Requirement[] reqs = obrResolver.getUnsatisfiedRequirements();
-            for (Requirement req : reqs) {
+            Reason[] reasons = obrResolver.getUnsatisfiedRequirements();
+            for (Reason reason : reasons) {
                 LOGGER.warn("Unable to resolve subsystem content {} subsystem resource {} because of unsatisfied requirement {}", 
-                        new Object[] {subsystemContent.toString(), subsystemResources.toString(), req.getName()});
+                        new Object[] {subsystemContent.toString(), subsystemResources.toString(), reason.getRequirement().getName()});
             }
 
         }

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java Thu Sep  2 16:19:13 2010
@@ -40,28 +40,29 @@ public class BundleInfoImpl implements B
 
     private Map<String, String> attributeMap = new HashMap<String, String>();
     private String path;
+    private Attributes attributes;
 
     public BundleInfoImpl(String pathToJar) {
-        this.path = pathToJar;
         Manifest manifest = null;
         try {
+        	File jarFile = new File(pathToJar);
+            this.path = jarFile.toURI().toURL().toString();
             JarFile f = new JarFile(new File(pathToJar));
             manifest = f.getManifest();
         } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-
         process(manifest);
     }
 
     private void process(Manifest manifest) {
         if (manifest != null) {
-            Attributes attributes = manifest.getMainAttributes();
-            Set<Object> set = attributes.keySet();
+            this.attributes = manifest.getMainAttributes();
+            Set<Object> set = this.attributes.keySet();
             for (Object entry : set) {
                 String key = entry.toString();
-                attributeMap.put(key, attributes.getValue(key));
+                attributeMap.put(key, this.attributes.getValue(key));
             }
         }
     }
@@ -134,4 +135,8 @@ public class BundleInfoImpl implements B
         return Version.parseVersion(attributeMap.get(Constants.BUNDLE_VERSION));
     }
 
+	public Attributes getRawAttributes() {
+        return this.attributes;
+	}
+
 }

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java Thu Sep  2 16:19:13 2010
@@ -28,7 +28,7 @@ import org.apache.aries.application.Cont
 import org.apache.aries.application.management.BundleInfo;
 import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
 import org.osgi.framework.Constants;
-import org.osgi.service.obr.Resource;
+import org.apache.felix.bundlerepository.Resource;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/MockRepositoryAdminImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/MockRepositoryAdminImpl.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/MockRepositoryAdminImpl.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/MockRepositoryAdminImpl.java Thu Sep  2 16:19:13 2010
@@ -18,44 +18,60 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.osgi.service.obr.Repository;
-import org.osgi.service.obr.RepositoryAdmin;
-import org.osgi.service.obr.Resolver;
-import org.osgi.service.obr.Resource;
+import org.apache.felix.bundlerepository.DataModelHelper;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Resolver;
+import org.apache.felix.bundlerepository.Resource;
+import org.osgi.framework.InvalidSyntaxException;
 
 public class MockRepositoryAdminImpl implements RepositoryAdmin {
 
     List<Repository> repos = new ArrayList<Repository>();
-    public MockRepositoryAdminImpl() {
-        
-    }
-    public Repository addRepository(URL arg0) throws Exception {
-        return null;
-        
-    }
-
-    public Resource[] discoverResources(String arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Resource getResource(String arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Repository[] listRepositories() {
-        return (Repository[]) repos.toArray();
-    }
-
-    public boolean removeRepository(URL arg0) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public Resolver resolver() {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
+	public Repository addRepository(String arg0) throws Exception {
+		return null;
+	}
+
+	public Repository addRepository(URL arg0) throws Exception {
+		return null;
+	}
+
+	public Resource[] discoverResources(String arg0)
+			throws InvalidSyntaxException {
+		return null;
+	}
+
+	public Resource[] discoverResources(Requirement[] arg0) {
+		return null;
+	}
+
+	public DataModelHelper getHelper() {
+		return null;
+	}
+
+	public Repository getLocalRepository() {
+		return null;
+	}
+
+	public Repository getSystemRepository() {
+		return null;
+	}
+
+	public Repository[] listRepositories() {
+		return (Repository[])repos.toArray();
+	}
+
+	public boolean removeRepository(String arg0) {
+		return false;
+	}
+
+	public Resolver resolver() {
+		return null;
+	}
+
+	public Resolver resolver(Repository[] arg0) {
+		return null;
+	}
 }

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/ResourceResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/ResourceResolverTest.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/ResourceResolverTest.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/ResourceResolverTest.java Thu Sep  2 16:19:13 2010
@@ -23,7 +23,7 @@ import org.apache.aries.unittest.mocks.S
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.obr.RepositoryAdmin;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
 
 public class ResourceResolverTest {
 

Modified: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java?rev=992005&r1=992004&r2=992005&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java Thu Sep  2 16:19:13 2010
@@ -115,7 +115,7 @@ public class SubsystemAdminTest extends 
         subsystem.start();
     }
 
-    @org.ops4j.pax.exam.junit.Configuration
+	@org.ops4j.pax.exam.junit.Configuration
     public static Option[] configuration() {
         Option[] options = options(
             // Log