You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2020/07/14 15:14:32 UTC
[sling-org-apache-sling-feature-extension-apiregions] branch master
updated: SLING-9521 Packages exported in earlier API Regions are not
available to later API Regions
This is an automated email from the ASF dual-hosted git repository.
davidb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-extension-apiregions.git
The following commit(s) were added to refs/heads/master by this push:
new 14b7ff1 SLING-9521 Packages exported in earlier API Regions are not available to later API Regions
new abfa05f Merge pull request #8 from bosschaert/SLING-9521
14b7ff1 is described below
commit 14b7ff157d09b453193c9802b8a5a68e7b7bea27
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Fri Jul 10 15:59:24 2020 +0100
SLING-9521 Packages exported in earlier API Regions are not available to later API Regions
To support this the launcher extension now puts a property in the
features.properties map that contains the total ordering of regions,
e.g.:
__region.order__=global,deprecated,internal
This commit also fixes the fact that the region values in the
features.properties map were unordered. Features have an order and this
is now preserved.
---
.../apiregions/launcher/LauncherProperties.java | 20 ++++++++++++++++----
.../apiregions/launcher/LauncherPropertiesTest.java | 7 ++++---
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java b/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
index 955db85..091450c 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.java
@@ -23,6 +23,8 @@ import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -43,6 +45,8 @@ import org.osgi.framework.Version;
public class LauncherProperties
{
+ private static final String REGION_ORDER = "__region.order__";
+
public static Properties getBundleIDtoBSNandVersionMap(Feature app, ArtifactProvider artifactProvider) {
Map<ArtifactId, String> map = new HashMap<>();
@@ -101,18 +105,22 @@ public class LauncherProperties
}
public static Properties getFeatureIDtoRegionsMap(ApiRegions regions) {
- Map<ArtifactId, Set<String>> map = new HashMap<>();
+ Map<ArtifactId, List<String>> map = new HashMap<>();
for (ApiRegion region : regions.listRegions())
{
for (ArtifactId featureId : region.getFeatureOrigins()) {
map.compute(featureId, (id, regionNames) -> {
if (regionNames == null) {
- regionNames = new HashSet<>();
+ regionNames = new LinkedList<>();
}
regionNames.add(region.getName());
+ int insertionIndex = regionNames.size() - 1;
for (ApiRegion parent = region.getParent(); parent != null; parent = parent.getParent()) {
- regionNames.add(parent.getName());
+ String parentName = parent.getName();
+ if (!regionNames.contains(parentName)) {
+ regionNames.add(insertionIndex, parentName);
+ }
}
return regionNames;
});
@@ -121,10 +129,14 @@ public class LauncherProperties
Properties result = new Properties();
- for (Map.Entry<ArtifactId, Set<String>> entry : map.entrySet()) {
+ for (Map.Entry<ArtifactId, List<String>> entry : map.entrySet()) {
result.setProperty(entry.getKey().toMvnId(), String.join(",", entry.getValue()));
}
+ result.put(REGION_ORDER, regions.listRegions().stream()
+ .map(ApiRegion::getName)
+ .collect(Collectors.joining(",")));
+
return result;
}
diff --git a/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java b/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
index 6fe8b28..99cea3d 100644
--- a/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
+++ b/src/test/java/org/apache/sling/feature/extension/apiregions/launcher/LauncherPropertiesTest.java
@@ -39,8 +39,8 @@ public class LauncherPropertiesTest
Assert.assertNotNull(properties);
Assert.assertEquals("region1,region2,region4", properties.getProperty("f:f1:1"));
-
Assert.assertEquals("region1,region2,region3", properties.getProperty("f:f2:1"));
+ Assert.assertEquals("region1,region2,region3,region4", properties.getProperty("__region.order__"));
}
@Test
@@ -50,14 +50,15 @@ public class LauncherPropertiesTest
"{\"name\": \"region1\", \"exports\": [\"org.foo.b\"],\"feature-origins\":[\"f:f1:1\"]}," +
"{\"name\": \"region2\", \"exports\": [\"org.foo.c\"],\"feature-origins\":[\"f:f1:1\"]}," +
"{\"name\": \"region3\", \"exports\": [],\"feature-origins\":[\"f:f2:1\"]}," +
- "{\"name\": \"region4\", \"exports\": [],\"feature-origins\":[\"f:f2:1\"]}" +
+ "{\"name\": \"region4\", \"exports\": [],\"feature-origins\":[\"f:f2:1\"]}," +
+ "{\"name\": \"region5\", \"exports\": [],\"feature-origins\":[\"f:f3:1\"]}" +
"]");
Properties properties = LauncherProperties.getFeatureIDtoRegionsMap(apiRegions);
Assert.assertNotNull(properties);
Assert.assertEquals("region1,region2", properties.getProperty("f:f1:1"));
-
Assert.assertEquals("region3,region4", properties.getProperty("f:f2:1"));
+ Assert.assertEquals("region1,region2,region3,region4,region5", properties.getProperty("__region.order__"));
}
}