Package org.apache.sling.feature.builder
Class FeatureBuilder
- java.lang.Object
-
- org.apache.sling.feature.builder.FeatureBuilder
-
public abstract class FeatureBuilder extends Object
-
-
Constructor Summary
Constructors Constructor Description FeatureBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Feature
assemble(ArtifactId featureId, BuilderContext context, Feature... features)
Assemble a feature based on the provided features.static Feature
assemble(Feature feature, BuilderContext context)
Assemble the full feature by processing its prototype.static Feature[]
deduplicate(BuilderContext context, Feature... features)
Remove duplicate and prototype features.static Feature[]
resolve(BuilderContext context, String... featureIds)
Resolve a set of features based on their ids.static void
resolveVariables(Feature feature, Map<String,String> additionalVariables)
Resolve variables in the feature.
-
-
-
Method Detail
-
assemble
public static Feature assemble(Feature feature, BuilderContext context)
Assemble the full feature by processing its prototype.- Parameters:
feature
- The feature to startcontext
- The builder context- Returns:
- The assembled feature.
- Throws:
IllegalArgumentException
- If feature or context isnull
IllegalStateException
- If a prototype feature can't be provided or merged.
-
resolve
public static Feature[] resolve(BuilderContext context, String... featureIds)
Resolve a set of features based on their ids.- Parameters:
context
- The builder contextfeatureIds
- The feature ids- Returns:
- An array of features, the array has the same order as the provided ids
- Throws:
IllegalArgumentException
- If context or featureIds isnull
IllegalStateException
- If the provided ids are invalid, or the feature can't be provided
-
deduplicate
public static Feature[] deduplicate(BuilderContext context, Feature... features)
Remove duplicate and prototype features. If a feature with the same id but different version is contained several times, only the one with the highest version is kept in the result list. If a feature has another feature as prototype from the provided set, the prototype feature is removed from the set.- Parameters:
context
- The builder contextfeatures
- A list of features- Returns:
- A list of features without duplicates.
-
assemble
public static Feature assemble(ArtifactId featureId, BuilderContext context, Feature... features)
Assemble a feature based on the provided features. The features are processed in the order they are provided. If the same feature is included more than once only the feature with the highest version is used. The others are ignored.- Parameters:
featureId
- The feature id to use.context
- The builder contextfeatures
- The features- Returns:
- The application
- Throws:
IllegalArgumentException
- If featureId, context or featureIds isnull
IllegalStateException
- If a feature can't be provided or the feature can't be assembled
-
resolveVariables
public static void resolveVariables(Feature feature, Map<String,String> additionalVariables)
Resolve variables in the feature. Variables are allowed in the values of framework properties and in the values of configuration properties.- Parameters:
feature
- The featureadditionalVariables
- Optional additional variables
-
-