Interface FlashExtension

All Known Implementing Classes:
BaseViewExtension, DataExtension, JacksonExtension, JteExtension, LimiterExtension, OidcExtension, OpenApiExtension, RouteViewerExtension, ThymeleafExtension, WebBundlerExtension

public interface FlashExtension
Two-phase contract for all Flash extensions.

Extension lifecycle inside FlashApp.start():

  1. Extensions are sorted by priority() — lower value runs first.
  2. Provide phaseprovide(FlashContext) is called for all installed extensions. Use this phase to register services, annotation processors, and route listeners. Never call FlashContext.require(java.lang.Class<T>) here.
  3. Context resolution — FlashContext.resolveAll() performs topological resolution of lazy suppliers. Circular or missing dependencies fail here with a clear message before any request is served.
  4. Routes phaseroutes(FlashRegistrar, FlashContext) is called for all extensions. All services are resolved; FlashContext.require(java.lang.Class<T>) is safe.

Priority and middleware ordering

priority() controls the order annotation processors are registered, which determines the annotation-layer middleware chain position:
 Request ──► EARLY processors' mw ──► DEFAULT processors' mw ──► LATE processors' mw ──► handler
 
Use ExtensionPhase constants for semantic ordering:

 @Override public int priority() { return ExtensionPhase.EARLY.value; }
 

Example


 public class MetricsExtension implements FlashExtension {

     @Override public int priority() { return ExtensionPhase.LATE.value; }

     @Override
     public void provide(FlashContext ctx) {
         ctx.provide(MetricsRegistry.class, new PromMetricsRegistry());
     }

     @Override
     public void routes(FlashRegistrar<?> app, FlashContext ctx) {
         app.get("/metrics", (req, res) -> ctx.require(MetricsRegistry.class).scrape());
     }
 }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Execution priority.
    default void
    Phase 1 — register services and processors.
    default void
    Phase 2 — register routes.