OnContextPrepared constructor

const OnContextPrepared()

Annotation to mark a method that should run when the application context has been prepared.

This lifecycle event occurs after the environment is set up and configuration has been applied, but before the context is refreshed and pods are fully initialized.

Use this for adjusting configuration, registering additional pods, or overriding defaults.

The only acceptable method signatures are:

  • No-Arg: The method should not accept any arguments.
  • One-Arg: The method should accept a single argument of type ConfigurableApplicationContext.

Example

class MyApp {
  @OnContextPrepared()
  void prepareContext() {
    print("Context prepared, applying additional configuration...");
  }

  @OnContextPrepared()
  void prepareContextWithContext(ConfigurableApplicationContext context) {
    print("Context prepared, applying additional configuration...");
  }
}

Implementation

const OnContextPrepared();