You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/06/19 22:24:32 UTC
[sling-whiteboard] branch master updated: [r2f] expanded the APIs
set, documentation updated
This is an automated email from the ASF dual-hosted git repository.
simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new ab286a3 [r2f] expanded the APIs set, documentation updated
ab286a3 is described below
commit ab286a3b32b52d9d501e62f1abcfd8c880f4944b
Author: Simo Tripodi <st...@adobe.com>
AuthorDate: Thu Jun 20 00:24:25 2019 +0200
[r2f] expanded the APIs set, documentation updated
---
runtime2feature/README.md | 27 ++++++++++++++--------
.../r2f/RuntimeEnvironment2FeatureModel.java | 2 ++
.../RuntimeEnvironment2FeatureModelService.java | 18 +++++++++++++++
3 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/runtime2feature/README.md b/runtime2feature/README.md
index 72de5b4..75798c8 100644
--- a/runtime2feature/README.md
+++ b/runtime2feature/README.md
@@ -2,6 +2,8 @@
# Apache Sling OSGi runtime environment to Feature Model generator
+## Runtime Feature
+
This is a simple OSGi service which is able to convert, given a `BundleContext` instance, a currently running OSGi container to an Apache Sling Feature Model definition.
APIs are really simple: it is necessary first to obtain the `RuntimeEnvironment2FeatureModel` instance from the OSGi Service Registry, then
@@ -9,17 +11,11 @@ APIs are really simple: it is necessary first to obtain the `RuntimeEnvironment2
```
import org.apache.sling.feature.r2f.*;
-@Activate
-BundleContext bundleContext;
-
@Reference
RuntimeEnvironment2FeatureModel generator;
...
-ConversionRequest conversionRequest = new DefaultConversionRequest()
- .setResultId("org.apache.sling:org.apache.sling.r2e:jar:RUNTIME:1.0.0")
- .setBundleContext(bundleContext);
-Feature runtimeFeature = generator.getRuntimeFeature(conversionRequest)
+Feature runtimeFeature = generator.getRuntimeFeature();
```
## Please Note
@@ -33,12 +29,23 @@ The `RuntimeEnvironment2FeatureModel` OSGi service is also able to retrieve the
```
import org.apache.sling.feature.r2f.*;
-@Activate
-BundleContext bundleContext;
+@Reference
+RuntimeEnvironment2FeatureModel generator;
+
+...
+Feature launchFeature = generator.getLaunchFeature();
+```
+
+## Upgrade Feature
+
+The `RuntimeEnvironment2FeatureModel` OSGi service is also able to compute the upgrade Feature which prototypes from the Feature used to launch the platform and that targets the runtime Feature:
+
+```
+import org.apache.sling.feature.r2f.*;
@Reference
RuntimeEnvironment2FeatureModel generator;
...
-Feature launchFeature = generator.getLaunchFeature(bundleContext)
+Feature launchFeature = generator.getLaunch2RuntimeUpgradingFeature();
```
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java
index c034a04..f6ae696 100644
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java
+++ b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/RuntimeEnvironment2FeatureModel.java
@@ -24,4 +24,6 @@ public interface RuntimeEnvironment2FeatureModel {
Feature getRuntimeFeature();
+ Feature getLaunch2RuntimeUpgradingFeature();
+
}
diff --git a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
index 7ad9c00..e4ea07b 100644
--- a/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
+++ b/runtime2feature/src/main/java/org/apache/sling/feature/r2f/impl/RuntimeEnvironment2FeatureModelService.java
@@ -17,6 +17,7 @@
package org.apache.sling.feature.r2f.impl;
import static java.nio.file.Files.newBufferedReader;
+import static org.apache.sling.feature.diff.FeatureDiff.compareFeatures;
import static org.apache.sling.feature.io.json.FeatureJSONReader.read;
import java.io.BufferedReader;
@@ -29,6 +30,7 @@ import java.util.stream.Stream;
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.diff.DiffRequest;
import org.apache.sling.feature.r2f.RuntimeEnvironment2FeatureModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -121,4 +123,20 @@ public class RuntimeEnvironment2FeatureModelService implements RuntimeEnvironmen
return targetFeature;
}
+ @Override
+ public Feature getLaunch2RuntimeUpgradingFeature() {
+ Feature runtimeFeature = getRuntimeFeature();
+
+ return compareFeatures(new DiffRequest()
+ .setPrevious(launchFeature)
+ .setCurrent(runtimeFeature)
+ .addIncludeComparator("bundles")
+ .addIncludeComparator("configurations")
+ .setResultId(new ArtifactId(runtimeFeature.getId().getGroupId(),
+ runtimeFeature.getId().getArtifactId(),
+ runtimeFeature.getId().getVersion(),
+ runtimeFeature.getId().getClassifier() + "_updater",
+ runtimeFeature.getId().getType())));
+ }
+
}