Ether Framework
Unified API docs for Ether modules
Loading...
Searching...
No Matches
dev.rafex.ether.di.Bootstrap Class Reference

Generic application bootstrap that wires a container with lifecycle management. More...

Collaboration diagram for dev.rafex.ether.di.Bootstrap:

Public Member Functions

record Runtime< C > (C container, Closer closer) implements AutoCloseable
 Immutable holder for the running application state.

Static Public Member Functions

static< C > Runtime< C > start (final Supplier< C > containerFactory)
 Convenience overload — starts without warmup or pre-shutdown callback.
static< C > Runtime< C > start (final Supplier< C > containerFactory, final Consumer< C > warmup)
 Convenience overload — starts without a pre-shutdown callback.
static< C > Runtime< C > start (final Supplier< C > containerFactory, final Consumer< C > warmup, final Consumer< C > onShutdown)
 Creates and starts the application.

Detailed Description

Generic application bootstrap that wires a container with lifecycle management.

Bootstrap ties together three lifecycle concerns:

  1. Creation — a Supplier builds the application-specific container.
  2. Warmup — an optional Consumer eagerly initializes all components so startup failures surface immediately instead of at first request.
  3. Shutdown — a JVM shutdown hook calls an optional pre-close callback, then closes the Closer in LIFO order.

The returned Runtime is AutoCloseable, so it integrates naturally with try-with-resources for graceful shutdown in tests and CLI applications.


var runtime = Bootstrap.start(
AppContainer::new, // factory
AppContainer::warmup, // fail-fast eager init
container -> {} // pre-shutdown callback
);

try (runtime) {
JettyServer.start(runtime.container());
}

This class has no public constructors — use the static factory methods.

Definition at line 62 of file Bootstrap.java.

Member Function Documentation

◆ Runtime< C >()

record dev.rafex.ether.di.Bootstrap.Runtime< C > ( C container,
Closer closer )

Immutable holder for the running application state.

Parameters
<C>type of the application container

Creates a Runtime; both parameters must be non-null.

Closes the underlying Closer, releasing all registered resources in LIFO order.

Definition at line 73 of file Bootstrap.java.

◆ start() [1/3]

static< C > Runtime< C > dev.rafex.ether.di.Bootstrap.start ( final Supplier< C > containerFactory)
static

Convenience overload — starts without warmup or pre-shutdown callback.

Parameters
<C>type of the application container
containerFactorysupplier that creates the container
Returns
a Runtime holding the container and its closer
See also
#start(Supplier, Consumer, Consumer)

Definition at line 165 of file Bootstrap.java.

References start().

Here is the call graph for this function:

◆ start() [2/3]

static< C > Runtime< C > dev.rafex.ether.di.Bootstrap.start ( final Supplier< C > containerFactory,
final Consumer< C > warmup )
static

Convenience overload — starts without a pre-shutdown callback.

Parameters
<C>type of the application container
containerFactorysupplier that creates the container
warmupoptional warmup consumer; null disables warmup
Returns
a Runtime holding the container and its closer
See also
#start(Supplier, Consumer, Consumer)

Definition at line 152 of file Bootstrap.java.

References start().

Here is the call graph for this function:

◆ start() [3/3]

static< C > Runtime< C > dev.rafex.ether.di.Bootstrap.start ( final Supplier< C > containerFactory,
final Consumer< C > warmup,
final Consumer< C > onShutdown )
static

Creates and starts the application.

Steps performed:

  1. Create a new Closer.
  2. Build the container via containerFactory.
  3. If the container implements AutoCloseable, register it with the closer.
  4. If warmup is non-null, invoke it — any exception aborts startup.
  5. Register a JVM shutdown hook that calls onShutdown (if non-null) then closes the closer.
Parameters
<C>type of the application container
containerFactorysupplier that creates the container; must not return null
warmupoptional consumer invoked after container creation to eagerly initialize all components; null disables warmup
onShutdownoptional consumer invoked on JVM shutdown before resources are closed; null disables the pre-shutdown callback
Returns
a Runtime holding the container and its closer

Definition at line 111 of file Bootstrap.java.

Referenced by start(), and start().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: