Class BuilderContext
FeatureBuilder
and controls how features are assembled and aggregated.
When two features are merged, being it a prototype with the feature using the prototype or two features, there might be a clash with bundles or artifacts. A clash occurs when there is an artifact in the source and the target with different versions. If the version is the same, the source artifact will override the target artifact. However, all other cases need instructions on how to proceed.
An override rule is an artifact id. As the version for the rule, one of
VERSION_OVERRIDE_ALL
,
VERSION_OVERRIDE_LATEST
or
VERSION_OVERRIDE_FIRST
or
VERSION_OVERRIDE_HIGHEST
as well as any version can be
specified. If the artifact id should match more than a single artifact
COORDINATE_MATCH_ALL
can be specified as group id,
artifact id, type and/or classifier.
A clash might also happen with framework properties or variables. In this case an override must be provided for that variable or framework property as well.
This class is not thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Used to handle configuration merging - fail the merge when there is a clash for a PID - this is the defaultstatic final String
Used to handle configuration merging - fail the merge only when there is a clash on a property levelstatic final String
Used to handle configuration merging - merge the first configuration in, latest props will not override previous valuesstatic final String
Used to handle configuration merging - merge the latest configuration in, latest props might override previous valuesstatic final String
Used to handle configuration merging - use the first configuration, don't mergestatic final String
Used to handle configuration merging - use the latest configuration, but don't mergestatic final String
Used in override rule to match all coordinatesstatic final String
Used in override rule to select all candidates.static final String
Used in override rule to select the first candidate applied.static final String
Used in override rule to select the candidate with the highest version (OSGi version comparison rules).static final String
Used in override rule to select the last candidate applied. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArtifactsOverride
(ArtifactId override) Add an override for artifact clashes.addConfigsOverrides
(Map<String, String> overrides) Add merge policies for configuration clashes.Add overrides for the framework properties.addMergeExtensions
(MergeHandler... extensions) Add merge extensionsaddPostProcessExtensions
(PostProcessHandler... extensions) Add post process extensionsaddVariablesOverrides
(Map<String, String> vars) Add overrides for the variables.Set the artifact provider.setHandlerConfiguration
(String name, Map<String, String> cfg) Set a handler configuration.
-
Field Details
-
VERSION_OVERRIDE_ALL
Used in override rule to select all candidates.- See Also:
-
VERSION_OVERRIDE_HIGHEST
Used in override rule to select the candidate with the highest version (OSGi version comparison rules).- See Also:
-
VERSION_OVERRIDE_LATEST
Used in override rule to select the last candidate applied.- See Also:
-
VERSION_OVERRIDE_FIRST
Used in override rule to select the first candidate applied.- Since:
- 1.3.0
- See Also:
-
COORDINATE_MATCH_ALL
Used in override rule to match all coordinates- See Also:
-
CONFIG_FAIL_ON_CLASH
Used to handle configuration merging - fail the merge when there is a clash for a PID - this is the default- See Also:
-
CONFIG_FAIL_ON_PROPERTY_CLASH
Used to handle configuration merging - fail the merge only when there is a clash on a property level- See Also:
-
CONFIG_USE_LATEST
Used to handle configuration merging - use the latest configuration, but don't merge- See Also:
-
CONFIG_USE_FIRST
Used to handle configuration merging - use the first configuration, don't merge- See Also:
-
CONFIG_MERGE_LATEST
Used to handle configuration merging - merge the latest configuration in, latest props might override previous values- See Also:
-
CONFIG_MERGE_FIRST
Used to handle configuration merging - merge the first configuration in, latest props will not override previous values- See Also:
-
-
Constructor Details
-
BuilderContext
Create a new context. The feature provider is for example used to get a prototype feature.- Parameters:
provider
- A provider providing required features for processing- Throws:
IllegalArgumentException
- If feature provider isnull
-
-
Method Details
-
setArtifactProvider
Set the artifact provider. While the artifact provider is not required by the general assembly and merging algorithms, handlers for extensions might need it.- Parameters:
ap
- An ArtifactProvider to resolve artifact IDs to URLs- Returns:
- The builder context
-
addVariablesOverrides
Add overrides for the variables. Variables can be overridden if any feature in the aggregation/assembly process contains an overriden variable. If multiple definitions of the same variable are found in the features that are to be aggregated and the values for these variables are different, they must be overridden, otherwise the aggregation will fail.- Parameters:
vars
- The overrides keyed by variable name- Returns:
- The builder context
-
addFrameworkPropertiesOverrides
Add overrides for the framework properties. Framework properties can be overridden if any feature in the aggregation/assembly process contains an overriden framework property. If multiple definitions of the same framework property are found in the features that are to be aggregated and the values for these properties are different, they must be overridden, otherwise the aggregation will fail.- Parameters:
props
- The overrides keyed by framework property name- Returns:
- The builder context
-
addArtifactsOverride
Add an override for artifact clashes.- Parameters:
override
- The override- Returns:
- The builder context
-
addConfigsOverrides
Add merge policies for configuration clashes.- Parameters:
overrides
- The overrides- Returns:
- The builder context
-
addMergeExtensions
Add merge extensions- Parameters:
extensions
- A list of merge extensions.- Returns:
- The builder context
-
addPostProcessExtensions
Add post process extensions- Parameters:
extensions
- A list of extensions- Returns:
- The builder context
-
setHandlerConfiguration
Set a handler configuration. A configuration can be set for bothMergeHandler
s andPostProcessHandler
s. The name of a handler is the simple class name of the class implementing the handler. To pass the same configuration to all handlers, use theCONFIGURATION_ALL_HANDLERS_KEY
name.- Parameters:
name
- The name of the handlercfg
- The configuration for the handler- Returns:
- The builder context
-