Annotation Interface ExtensionPoint


@Target({METHOD,TYPE}) @Retention(CLASS) public @interface ExtensionPoint

Extension points allow other features to further configure this feature during setup (contribute to the extension point). For example, a PaymentFeature could provide an extension point PaymentMethods that allows other features to contribute payment methods:

   @Feature
   class CreditCardPaymentFeature {

     @Provision
     public CreditCardPaymentMethod creditCardPaymentMethod() {
       return new CreditCardPaymentMethod();
     }

     @Setup
     protected void setupCreditCardPayment(PaymentMethods paymentMethods) {
       paymentMethods.add("Credit Card", this::creditCardPaymentMethod);
     }
   }

Preferably, extension point classes are designed for an expressive, DSL-like syntax, e.g. using fluent builder APIs.

Important: Extension points must be used exclusively in setup methods. Unfortunately, there's no way for Meld to protect extension points from escaping the setup method (e.g. by assigning them to a field), it's the programmers responsibility to not do this.

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).

See Also: