You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by tj...@apache.org on 2017/05/31 21:13:21 UTC

svn commit: r1797110 - in /aries/branches/java6support/subsystem: ./ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-itests/ subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ subsystem-itests/src/test/re...

Author: tjwatson
Date: Wed May 31 21:13:21 2017
New Revision: 1797110

URL: http://svn.apache.org/viewvc?rev=1797110&view=rev
Log:
Merge ^/aries/trunk/subsystem r1787234 through r1797109 into java6support branch.

Added:
    aries/branches/java6support/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoBSNTest.java
      - copied unchanged from r1797109, aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoBSNTest.java
    aries/branches/java6support/subsystem/subsystem-itests/src/test/resources/nobsn/
      - copied from r1797109, aries/trunk/subsystem/subsystem-itests/src/test/resources/nobsn/
Modified:
    aries/branches/java6support/subsystem/   (props changed)
    aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
    aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
    aries/branches/java6support/subsystem/subsystem-itests/pom.xml

Propchange: aries/branches/java6support/subsystem/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 31 21:13:21 2017
@@ -1,2 +1,2 @@
 /aries/branches/1.0-prototype/subsystem:1306564-1337594
-/aries/trunk/subsystem:1728111-1787233
+/aries/trunk/subsystem:1728111-1797109

Modified: aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java?rev=1797110&r1=1797109&r2=1797110&view=diff
==============================================================================
--- aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java (original)
+++ aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java Wed May 31 21:13:21 2017
@@ -28,6 +28,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 
 import org.apache.aries.subsystem.core.archive.BundleManifest;
 import org.apache.aries.subsystem.core.archive.BundleRequiredExecutionEnvironmentHeader;
@@ -49,6 +50,7 @@ import org.apache.aries.subsystem.core.a
 import org.apache.aries.util.filesystem.IDirectory;
 import org.apache.aries.util.filesystem.IFile;
 import org.apache.aries.util.io.IOUtils;
+import org.osgi.framework.Constants;
 import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
@@ -56,10 +58,18 @@ import org.osgi.resource.Resource;
 import org.osgi.service.subsystem.SubsystemException;
 
 public class BundleResource implements Resource, org.apache.aries.subsystem.core.repository.RepositoryContent {
-	private static BundleManifest computeManifest(IDirectory directory) {
-		return new BundleManifest(org.apache.aries.util.manifest.BundleManifest
-				.fromBundle(directory)
-				.getRawManifest());
+	private static BundleManifest computeManifest(IDirectory directory, IFile content) {
+		org.apache.aries.util.manifest.BundleManifest bm = 
+				org.apache.aries.util.manifest.BundleManifest.fromBundle(directory);
+		if (bm == null) {
+			throw new IllegalArgumentException("File \"" + content.getName() + "\" contains no bundle manifest META-INF/MANIFEST.MF.");
+		}
+		Manifest m = bm.getRawManifest();
+		BundleManifest result = new BundleManifest(m);
+		if (result.getHeader(Constants.BUNDLE_SYMBOLICNAME) == null) {
+			throw new IllegalArgumentException("File \"" + content.getName() + "\" has a META-INF/MANIFEST.MF with no Bundle-SymbolicName header.");
+		}
+		return result;
 	}
 	
 	private final List<Capability> capabilities = new ArrayList<Capability>();
@@ -70,7 +80,7 @@ public class BundleResource implements R
 	public BundleResource(IFile content) {
 		this.content = content;
 		IDirectory dir = content.isDirectory() ? content.convert() : content.convertNested();
-		manifest = computeManifest(dir);
+		manifest = computeManifest(dir, content);
 		computeRequirementsAndCapabilities(dir);
 	}
 

Modified: aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java?rev=1797110&r1=1797109&r2=1797110&view=diff
==============================================================================
--- aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java (original)
+++ aries/branches/java6support/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java Wed May 31 21:13:21 2017
@@ -455,7 +455,7 @@ public class RawSubsystemResource implem
 		for (IFile file : directory.listFiles()) {
             if (file.isFile()) {
                 addResource(file, file.convertNested(), manifest, result);
-            } else {
+            } else if (!file.getName().endsWith("OSGI-INF")) {
                 addResource(file, file.convert(), manifest, result);
             }
 		}
@@ -467,9 +467,16 @@ public class RawSubsystemResource implem
             IOException, ResolutionException, MalformedURLException {
         String name = file.getName();
         if (name.endsWith(".esa")) {
-        	result.add(new RawSubsystemResource(convertFileToLocation(file), content, parentSubsystem));
+            result.add(new RawSubsystemResource(convertFileToLocation(file), content, parentSubsystem));
         } else if (name.endsWith(".jar")) {
-            result.add(new BundleResource(file));
+            try {
+                result.add(new BundleResource(file));
+            } catch (IllegalArgumentException e) {
+                // Ignore if the resource is an invalid bundle or not a bundle at all.
+                if (logger.isDebugEnabled()) {
+                    logger.debug("File \"" + file.getName() + "\" in subsystem with location \"" + location + "\" will be ignored because it is not recognized as a supported resource.", e);
+                }
+            }
         } else {
             // This is a different type of file. Add a file resource for it if there is a custom content handler for it.
             FileResource fr = new FileResource(file);
@@ -493,7 +500,7 @@ public class RawSubsystemResource implem
             } catch (Exception e) {
                 // Ignore if the resource is an invalid bundle or not a bundle at all.
                 if (logger.isDebugEnabled()) {
-                    logger.debug("File \"" + file.getName() + "\" in subsystem with location \"" + location + "\" will be ignored because it is not recognized as a supported resource", e);
+                    logger.debug("File \"" + file.getName() + "\" in subsystem with location \"" + location + "\" will be ignored because it is not recognized as a supported resource.", e);
                 }
             }
         }

Modified: aries/branches/java6support/subsystem/subsystem-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/java6support/subsystem/subsystem-itests/pom.xml?rev=1797110&r1=1797109&r2=1797110&view=diff
==============================================================================
--- aries/branches/java6support/subsystem/subsystem-itests/pom.xml (original)
+++ aries/branches/java6support/subsystem/subsystem-itests/pom.xml Wed May 31 21:13:21 2017
@@ -332,6 +332,21 @@
                 <artifactId>maven-jar-plugin</artifactId>
                 <version>2.3</version>
                 <executions>
+                     <execution>
+                        <id>tb1-nobsn</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <excludes>
+                                <exclude>**/*</exclude>
+                            </excludes>
+                            <classesDirectory>${project.build.directory}/test-classes</classesDirectory>
+                            <outputDirectory>${project.build.directory}/test-classes/nobsn</outputDirectory>
+                            <finalName>tb1</finalName>
+                        </configuration>
+                        <phase>process-test-classes</phase>
+                    </execution>
                     <execution>
                         <id>tb1-application1</id>
                         <goals>