Package dev.relism.flash.extension
Class FlashContext
java.lang.Object
dev.relism.flash.extension.FlashContext
Deterministic boot-time service graph, frozen before handlers are initialised.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotationProcessor(AnnotationProcessor processor) voidaddRouteListener(RouteListener listener) child()voidcomplete()Completes graph resolution and runs all deferred materialisation callbacks once.<T> Optional<T> voidRegisters cleanup to run when the app stops, after in-flight requests have drained.voidRegisters work materialised after all services are resolved.<T> Optional<T> <T> voidReplaces the binding fortype, whether or not one already exists.<T> voidBinds an already-created singleton.<T> T<T> voidsupply(Class<T> type, FlashContext.ServiceFactory<T> factory, Class<?>... dependencies) Declares a boot factory and its complete dependency set.<A,T> void One-dependency factory with no application-side context lookup.<T> voidDeclares a no-dependency boot factory.
-
Constructor Details
-
FlashContext
public FlashContext()
-
-
Method Details
-
child
-
provide
Binds an already-created singleton. Duplicate bindings are always an error. -
override
Replaces the binding fortype, whether or not one already exists.The declaration rule everywhere else is that a duplicate is an error (
provide(java.lang.Class<T>, T),supply(java.lang.Class<T>, java.util.function.Supplier<T>)); this is the single deliberate exception, and it exists for tests —flash-testinginstalls overrides as the last extension so a fake wins over whatever the application or an extension declared. Using it in production code is legal but almost always a mistake, so a replacement is logged. -
supply
Declares a no-dependency boot factory. -
supply
public <T> void supply(Class<T> type, FlashContext.ServiceFactory<T> factory, Class<?>... dependencies) Declares a boot factory and its complete dependency set. -
supply
One-dependency factory with no application-side context lookup. -
onReady
Registers work materialised after all services are resolved. -
onClose
Registers cleanup to run when the app stops, after in-flight requests have drained.Deliberately callable outside
DECLARINGso a factory can register its own teardown while it is being resolved:ctx.supply(DataSource.class, c -> { HikariDataSource ds = new HikariDataSource(cfg); c.onClose(ds::close); return ds; }); -
require
-
find
-
optional
-
addAnnotationProcessor
-
addRouteListener
-
complete
public void complete()Completes graph resolution and runs all deferred materialisation callbacks once.
-