Annotation Interface Configuration


@Documented @Target(TYPE) @Retention(CLASS) public @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 Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Additional features to mount.
    boolean
    Make the shell package local or public.
    The name of the shell class.
  • Element Details

    • mount

      Class<?>[] mount
      Additional features to mount.
      Default:
      {}
    • shellName

      String shellName
      The name of the shell class.
      Default:
      "*Shell"
    • packageLocal

      boolean packageLocal
      Make the shell package local or public.
      Default:
      true