Author: pauls
Date: Mon Feb 3 23:46:52 2020
New Revision: 1873562
URL: http://svn.apache.org/viewvc?rev=1873562&view=rev
Log:
Change the version to 0.1.0-SNAPSHOT and implement propagation for symbolic
name attributes
Modified:
felix/sandbox/pauls/connect/pom.xml
felix/sandbox/pauls/connect/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
felix/sandbox/pauls/connect/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
Modified: felix/sandbox/pauls/connect/pom.xml
URL:
http://svn.apache.org/viewvc/felix/sandbox/pauls/connect/pom.xml?rev=1873562&r1=1873561&r2=1873562&view=diff
==============================================================================
--- felix/sandbox/pauls/connect/pom.xml (original)
+++ felix/sandbox/pauls/connect/pom.xml Mon Feb 3 23:46:52 2020
@@ -27,7 +27,7 @@
<packaging>bundle</packaging>
<name>Apache Felix Framework</name>
<artifactId>org.apache.felix.framework.connect</artifactId>
- <version>0.1.0-CONNECT</version>
+ <version>0.1.0-SNAPSHOT</version>
<properties>
<dollar>$</dollar>
<felix.java.version>8</felix.java.version>
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=1873562&r1=1873561&r2=1873562&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
Mon Feb 3 23:46:52 2020
@@ -30,7 +30,6 @@ 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;
@@ -41,10 +40,12 @@ import org.osgi.framework.wiring.BundleR
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -113,7 +114,7 @@ public class ManifestParser
// Parse bundle symbolic name.
//
- BundleCapabilityImpl bundleCap = parseBundleSymbolicName(owner,
m_headerMap);
+ BundleCapabilityImpl bundleCap = parseBundleSymbolicName(logger,
owner, m_headerMap);
if (bundleCap != null)
{
m_bundleSymbolicName = (String)
@@ -700,7 +701,7 @@ public class ManifestParser
throws BundleException
{
- if (!mv.equals("2") && !clauses.isEmpty())
+ if (mv != null && !mv.equals("2") && !clauses.isEmpty())
{
// Should we error here if we are not an R4 bundle?
}
@@ -1362,12 +1363,12 @@ public class ManifestParser
return false;
}
- private static BundleCapabilityImpl parseBundleSymbolicName(
+ private static BundleCapabilityImpl parseBundleSymbolicName(Logger logger,
BundleRevision owner, Map<String, Object> headerMap)
throws BundleException
{
- List<ParsedHeaderClause> clauses = parseStandardHeader(
- (String) headerMap.get(Constants.BUNDLE_SYMBOLICNAME));
+ List<ParsedHeaderClause> clauses = normalizeCapabilityClauses(logger,
parseStandardHeader(
+ (String) headerMap.get(Constants.BUNDLE_SYMBOLICNAME)),
getManifestVersion(headerMap));
if (clauses.size() > 0)
{
if (clauses.size() > 1)
@@ -1382,6 +1383,11 @@ public class ManifestParser
"Cannot have multiple symbolic names: "
+ headerMap.get(Constants.BUNDLE_SYMBOLICNAME));
}
+ else if
(clauses.get(0).m_attrs.containsKey(Constants.BUNDLE_VERSION))
+ {
+ throw new BundleException(
+ "Cannot have a bundle version: " +
headerMap.get(Constants.BUNDLE_VERSION));
+ }
// Get bundle version.
Version bundleVersion = Version.emptyVersion;
@@ -1404,6 +1410,48 @@ public class ManifestParser
}
}
+ Object tagList =
clauses.get(0).m_attrs.get(IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE);
+ LinkedHashSet<String> tags = new LinkedHashSet<>();
+ if (tagList != null)
+ {
+ if (tagList instanceof List)
+ {
+ for (Object member : ((List) tagList))
+ {
+ if (member instanceof String)
+ {
+ tags.add((String) member);
+ }
+ else
+ {
+ throw new BundleException("Invalid tags list: " +
headerMap.get(Constants.BUNDLE_SYMBOLICNAME));
+ }
+ }
+ }
+ else if (tagList instanceof String)
+ {
+ tags.add((String) tagList);
+ }
+ else
+ {
+ throw new BundleException("Invalid tags list: " +
headerMap.get(Constants.BUNDLE_SYMBOLICNAME));
+ }
+ }
+
+ if (tags.contains(ConnectContent.TAG_OSGI_CONNECT))
+ {
+ throw new BundleException("Invalid tags list: " +
headerMap.get(Constants.BUNDLE_SYMBOLICNAME));
+ }
+ if (owner != null && ((BundleRevisionImpl) owner).getContent()
instanceof ConnectContentContent)
+ {
+ tags.add(ConnectContent.TAG_OSGI_CONNECT);
+ }
+
+ if (!tags.isEmpty())
+ {
+
clauses.get(0).m_attrs.put(IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE, new
ArrayList<>(tags));
+ }
+
// Create a require capability and return it.
String symName = (String) clauses.get(0).m_paths.get(0);
clauses.get(0).m_attrs.put(BundleRevision.BUNDLE_NAMESPACE,
symName);
@@ -1419,9 +1467,9 @@ public class ManifestParser
}
private static BundleCapabilityImpl addIdentityCapability(BundleRevision
owner,
- Map<String, Object> headerMap, BundleCapabilityImpl bundleCap)
+ Map<String, Object> headerMap, BundleCapabilityImpl bundleCap) throws
BundleException
{
- Map<String, Object> attrs = new HashMap<String, Object>();
+ Map<String, Object> attrs = new HashMap<String,
Object>(bundleCap.getAttributes());
attrs.put(IdentityNamespace.IDENTITY_NAMESPACE,
bundleCap.getAttributes().get(BundleNamespace.BUNDLE_NAMESPACE));
@@ -1453,10 +1501,6 @@ 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/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=1873562&r1=1873561&r2=1873562&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
Mon Feb 3 23:46:52 2020
@@ -66,7 +66,7 @@ public class ManifestParserTest extends
{
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(Constants.BUNDLE_MANIFESTVERSION, "2");
- headers.put(Constants.BUNDLE_SYMBOLICNAME, "abc;singleton:=true");
+ headers.put(Constants.BUNDLE_SYMBOLICNAME,
"abc;singleton:=true;foo=bar;" + IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE +
"=test");
headers.put(Constants.BUNDLE_VERSION, "1.2.3.something");
String copyright = "(c) 2013 Apache Software Foundation";
headers.put(Constants.BUNDLE_COPYRIGHT, copyright);
@@ -92,7 +92,8 @@ 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(Arrays.asList("test", ConnectContent.TAG_OSGI_CONNECT),
ic.getAttributes().get(IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE));
+ assertEquals("bar", ic.getAttributes().get("foo"));
assertEquals(1, ic.getDirectives().size());
assertEquals("true",
ic.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));