This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature.git
The following commit(s) were added to refs/heads/master by this push:
new 2d1ec06 SLING-8064 : Support marking a feature as final
2d1ec06 is described below
commit 2d1ec0635dd28574a46d1cd48fc5d64d057eabc0
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Oct 31 14:19:29 2018 +0100
SLING-8064 : Support marking a feature as final
---
.../java/org/apache/sling/feature/Feature.java | 26 +++++++++++++++++++++-
.../sling/feature/builder/FeatureBuilder.java | 4 ++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/feature/Feature.java
b/src/main/java/org/apache/sling/feature/Feature.java
index 7e439c2..63dc52b 100644
--- a/src/main/java/org/apache/sling/feature/Feature.java
+++ b/src/main/java/org/apache/sling/feature/Feature.java
@@ -75,6 +75,8 @@ public class Feature implements Comparable<Feature> {
/** Flag indicating whether this is an assembled feature */
private volatile boolean assembled = false;
+ /** Flag indicating whether this is a final feature */
+ private volatile boolean finalFlag = false;
/** The optional include. */
private volatile Include include;
@@ -259,8 +261,29 @@ public class Feature implements Comparable<Feature> {
}
/**
+ * Check whether the feature is final A final feature can't be included by
other
+ * features.
+ *
+ * @return {@code true} if it is final, {@code false} otherwise
+ */
+ public boolean isFinal() {
+ return finalFlag;
+ }
+
+ /**
+ * Set the final flag
+ *
+ * @param flag The flag
+ */
+ public void setFinal(final boolean flag) {
+ this.finalFlag = flag;
+ }
+
+ /**
* Check whether the feature is already assembled
- * @return {@code true} if it is assembled, {@code false} if it needs to
be assembled
+ *
+ * @return {@code true} if it is assembled, {@code false} if it needs to be
+ * assembled
*/
public boolean isAssembled() {
return assembled;
@@ -297,6 +320,7 @@ public class Feature implements Comparable<Feature> {
result.setVendor(this.getVendor());
result.setLicense(this.getLicense());
result.setAssembled(this.isAssembled());
+ result.setFinal(this.isFinal());
// variables
result.getVariables().putAll(this.getVariables());
diff --git a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
index 739d82d..7af8ed3 100644
--- a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
+++ b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
@@ -302,6 +302,10 @@ public abstract class FeatureBuilder {
if ( f == null ) {
throw new IllegalStateException("Unable to find included
feature " + i.getId());
}
+ if (f.isFinal()) {
+ throw new IllegalStateException(
+ "Included feature " + i.getId() + " is marked as final
and can't be used in an include.");
+ }
final Feature af = internalAssemble(processedFeatures, f, context);
// process include instructions