You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pa...@apache.org on 2020/01/30 22:27:51 UTC
svn commit: r1873387 - in /felix/sandbox/pauls/connect/src:
main/java/org/apache/felix/framework/
main/java/org/apache/felix/framework/util/
main/java/org/apache/felix/framework/util/manifestparser/
main/java/org/osgi/framework/namespace/ test/java/org...
Author: pauls
Date: Thu Jan 30 22:27:51 2020
New Revision: 1873387
URL: http://svn.apache.org/viewvc?rev=1873387&view=rev
Log:
Add the osgi.connnect tag to the osgi.identity and don't add connected modules as extension bundles
Modified:
felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/ExtensionManager.java
felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/Util.java
felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
felix/sandbox/pauls/connect/src/main/java/org/osgi/framework/namespace/IdentityNamespace.java
felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
Modified: felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=1873387&r1=1873386&r2=1873387&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/ExtensionManager.java Thu Jan 30 22:27:51 2020
@@ -18,6 +18,7 @@
*/
package org.apache.felix.framework;
+import org.apache.felix.framework.cache.ConnectContentContent;
import org.apache.felix.framework.cache.Content;
import org.apache.felix.framework.cache.DirectoryContent;
import org.apache.felix.framework.cache.JarContent;
@@ -425,23 +426,6 @@ class ExtensionManager implements Conten
((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
.getHeaders().get(Constants.FRAGMENT_HOST));
- if (!Constants.EXTENSION_FRAMEWORK.equals(directive))
- {
- throw new BundleException("Unsupported Extension Bundle type: " +
- directive, new UnsupportedOperationException(
- "Unsupported Extension Bundle type!"));
- }
- else if (m_extenderFramework == null)
- {
- // We don't support extensions
- m_logger.log(bundle, Logger.LOG_WARNING,
- "Unable to add extension bundle - Maybe ClassLoader is not supported " +
- "(on java9, try --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED)?");
-
- throw new UnsupportedOperationException(
- "Unable to add extension bundle.");
- }
-
Content content = bundle.adapt(BundleRevisionImpl.class).getContent();
final File file;
if (content instanceof JarContent)
@@ -456,14 +440,31 @@ class ExtensionManager implements Conten
{
file = null;
}
- if (file == null)
+ if (file == null && !(content instanceof ConnectContentContent))
{
// We don't support revision type for extension
m_logger.log(bundle, Logger.LOG_WARNING,
- "Unable to add extension bundle - wrong revision type?");
+ "Unable to add extension bundle - wrong revision type?");
+
+ throw new UnsupportedOperationException(
+ "Unable to add extension bundle.");
+ }
+
+ if (!Constants.EXTENSION_FRAMEWORK.equals(directive))
+ {
+ throw new BundleException("Unsupported Extension Bundle type: " +
+ directive, new UnsupportedOperationException(
+ "Unsupported Extension Bundle type!"));
+ }
+ else if (m_extenderFramework == null && file != null)
+ {
+ // We don't support extensions
+ m_logger.log(bundle, Logger.LOG_WARNING,
+ "Unable to add extension bundle - Maybe ClassLoader is not supported " +
+ "(on java9, try --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED)?");
throw new UnsupportedOperationException(
- "Unable to add extension bundle.");
+ "Unable to add extension bundle.");
}
BundleRevisionImpl bri = bundle.adapt(BundleRevisionImpl.class);
@@ -574,21 +575,25 @@ class ExtensionManager implements Conten
{
f = ((DirectoryContent) revisionContent).getFile();
}
- try
+ if (f != null)
{
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
+ try
{
- @Override
- public Void run() throws Exception {
- m_extenderFramework.add(f);
- return null;
- }
- });
- }
- catch (Exception ex)
- {
- m_logger.log(revision.getBundle(), Logger.LOG_ERROR,
- "Error adding extension bundle to framework classloader: " + revision.getBundle(), ex);
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
+ {
+ @Override
+ public Void run() throws Exception
+ {
+ m_extenderFramework.add(f);
+ return null;
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ m_logger.log(revision.getBundle(), Logger.LOG_ERROR,
+ "Error adding extension bundle to framework classloader: " + revision.getBundle(), ex);
+ }
}
felix.setBundleStateAndNotify(revision.getBundle(), Bundle.RESOLVED);
Modified: felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/Util.java?rev=1873387&r1=1873386&r2=1873387&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/Util.java Thu Jan 30 22:27:51 2020
@@ -216,7 +216,7 @@ public class Util
}
catch (Exception ex)
{
- ex.printStackTrace();
+ //ex.printStackTrace();
// Not much we can do - probably not on java9
}
return result;
Modified: felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=1873387&r1=1873386&r2=1873387&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Thu Jan 30 22:27:51 2020
@@ -29,6 +29,8 @@ import org.osgi.framework.BundleExceptio
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
import org.osgi.framework.VersionRange;
+import org.osgi.framework.connect.ConnectContent;
+import org.osgi.framework.connect.ConnectModule;
import org.osgi.framework.namespace.BundleNamespace;
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
import org.osgi.framework.namespace.IdentityNamespace;
@@ -38,6 +40,7 @@ import org.osgi.framework.wiring.BundleR
import org.osgi.framework.wiring.BundleRevision;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -1450,6 +1453,10 @@ public class ManifestParser
attrs.put(IdentityNamespace.CAPABILITY_LICENSE_ATTRIBUTE,
headerMap.get(BUNDLE_LICENSE_HEADER));
}
+ if (owner != null && ((BundleRevisionImpl) owner).getContent() instanceof ConnectContentContent)
+ {
+ attrs.put(IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE, Arrays.asList(ConnectContent.TAG_OSGI_CONNECT));
+ }
Map<String, String> dirs;
if (bundleCap.getDirectives().get(Constants.SINGLETON_DIRECTIVE) != null)
Modified: felix/sandbox/pauls/connect/src/main/java/org/osgi/framework/namespace/IdentityNamespace.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/main/java/org/osgi/framework/namespace/IdentityNamespace.java?rev=1873387&r1=1873386&r2=1873387&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/main/java/org/osgi/framework/namespace/IdentityNamespace.java (original)
+++ felix/sandbox/pauls/connect/src/main/java/org/osgi/framework/namespace/IdentityNamespace.java Thu Jan 30 22:27:51 2020
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2012, 2013). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2019). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ import org.osgi.resource.Namespace;
* capability.
*
* @Immutable
- * @author $Id: 7bc7a11c45b30538ffbb7572c4539f6160557684 $
+ * @author $Id: 9d6919eafe3107b8326283f332e07c93077d4d69 $
*/
public final class IdentityNamespace extends Namespace {
@@ -105,6 +105,16 @@ public final class IdentityNamespace ext
public static final String TYPE_UNKNOWN = "unknown";
/**
+ * The attribute value that contains tags for the resource. A tag is used to
+ * identify an aspect of the resource that is not otherwise expressed by the
+ * capabilities of the resource. The value of this attribute must be of type
+ * {@code List<Version>}.
+ *
+ * @since 1.2
+ */
+ public static final String CAPABILITY_TAGS_ATTRIBUTE = "tags";
+
+ /**
* The capability attribute that contains a human readable copyright notice
* for the resource. See the {@code Bundle-Copyright} manifest header.
*/
Modified: felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java?rev=1873387&r1=1873386&r2=1873387&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java (original)
+++ felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java Thu Jan 30 22:27:51 2020
@@ -28,6 +28,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.felix.framework.BundleRevisionImpl;
+import org.apache.felix.framework.cache.ConnectContentContent;
+import org.apache.felix.framework.cache.Content;
import org.apache.felix.framework.util.FelixConstants;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -35,6 +38,7 @@ import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.Version;
+import org.osgi.framework.connect.ConnectContent;
import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.framework.namespace.NativeNamespace;
import org.osgi.framework.wiring.BundleCapability;
@@ -72,7 +76,13 @@ public class ManifestParserTest extends
headers.put(Constants.BUNDLE_DOCURL, docurl);
String license = "http://www.apache.org/licenses/LICENSE-2.0";
headers.put("Bundle-License", license);
- ManifestParser mp = new ManifestParser(null, null, null, headers);
+
+ BundleRevisionImpl mockBundleRevision = mock(BundleRevisionImpl.class);
+
+ Content connectContent = mock(ConnectContentContent.class);
+ when(mockBundleRevision.getContent()).thenReturn(connectContent);
+
+ ManifestParser mp = new ManifestParser(null, null, mockBundleRevision, headers);
BundleCapability ic = findCapability(mp.getCapabilities(), IdentityNamespace.IDENTITY_NAMESPACE);
assertEquals("abc", ic.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE));
@@ -82,6 +92,7 @@ public class ManifestParserTest extends
assertEquals(description, ic.getAttributes().get(IdentityNamespace.CAPABILITY_DESCRIPTION_ATTRIBUTE));
assertEquals(docurl, ic.getAttributes().get(IdentityNamespace.CAPABILITY_DOCUMENTATION_ATTRIBUTE));
assertEquals(license, ic.getAttributes().get(IdentityNamespace.CAPABILITY_LICENSE_ATTRIBUTE));
+ assertEquals(Arrays.asList(ConnectContent.TAG_OSGI_CONNECT), ic.getAttributes().get(IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE));
assertEquals(1, ic.getDirectives().size());
assertEquals("true", ic.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));
@@ -97,7 +108,10 @@ public class ManifestParserTest extends
"osgi.native.osversion:Version=\"7.0\";"+
"osgi.native.processor:List<String>=\"x86-64,amd64,em64t,x86_64\";"+
"osgi.native.language=\"en\"");
- BundleRevision mockBundleRevision = mock(BundleRevision.class);
+
+ BundleRevisionImpl mockBundleRevision = mock(BundleRevisionImpl.class);
+
+ when(mockBundleRevision.getContent()).thenReturn(null);
when(mockBundleRevision.getSymbolicName()).thenReturn(FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME);
ManifestParser mp = new ManifestParser(null, null, mockBundleRevision, headers);
@@ -123,7 +137,9 @@ public class ManifestParserTest extends
headers.put(Constants.REQUIRE_CAPABILITY,
"com.example.other;theList:List<String>=\"one,two,three\";theLong:Long=999");
- BundleRevision mockBundleRevision = mock(BundleRevision.class);
+ BundleRevisionImpl mockBundleRevision = mock(BundleRevisionImpl.class);
+
+ when(mockBundleRevision.getContent()).thenReturn(null);
when(mockBundleRevision.getSymbolicName()).thenReturn("com.example.test.sample");
@@ -154,7 +170,10 @@ public class ManifestParserTest extends
String[] languages = {"en", "se"};
String selectionFilter = "(com.acme.windowing=win32)";
NativeLibraryClause clause = new NativeLibraryClause(libraryFiles, osNames, processors, osVersions, languages, selectionFilter);
- BundleRevision owner = mock(BundleRevision.class);
+
+ BundleRevisionImpl owner = mock(BundleRevisionImpl.class);
+
+ when(owner.getContent()).thenReturn(null);
nativeLibraryClauses.add(clause);
List<BundleRequirement> nativeBundleReq = ManifestParser.convertNativeCode(owner, nativeLibraryClauses, false);