Annotation Interface Configuration
A configuration represents a set of feature implementation that together
form a whole (application, EJB, whatever). This is mostly done by
mounting (@Mount) multiple features.
The annotation processor will generate a class MyConfigurationShell that acts as entry point with a nested class Builder. Example code to construct an instance of a configuration:
@Configuration
abstract class MyConfiguration {
// (mounts, provisions, setup methods etc)
static MyConfiguration create(Config cfg) {
return MyConfigurationShell.builder().config(cfg).build();
}
}
A configuration can itself do everything that a feature can do, i.e. declare provisions, configuration parameters, extension points and setup methods.
Provisions: All provisions that are mounted from features are added to the configuration. There can be only one implementation of a provision, otherwise, it's considered a conflict and therefore an error. If no implementation can be found for a declared or mounted feature, it's also an error. The actual type of the provision will be the type declared by the implementation. Abstract provisions with a contravariant type (a super type of the actual type) are fine, covariants (or invariants, obviously) are not.
Construction: During construction, all setup methods of the configuration and all mounted features are called. Arguments of setup methods will be resolved from all declared or mounted extension points. Exactly one extension point must match the declared type. If multiple extension points match, it's considered a conflict and therefore an error, if none match, it's considered unresolved and also an error.
Thread-safety: All mounted features and the
configuration implementation itself will be assigned to a final field and
all setup methods will be called from the constructor. Therefore, all
actions in constructors and setup methods happen-before the
build() method exits, as long as no objects escape the object
tree under construction
(JLS
17.5).
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]Additional features to mount.booleanMake the shell package local or public.The name of the shell class.