ContextRefreshedEvent.withClock constructor

ContextRefreshedEvent.withClock(
  1. ApplicationContext source,
  2. DateTime clock()
)

Event published when the ApplicationContext is refreshed or initialized.

This event is emitted after the application context has been fully configured, all singleton pods have been instantiated, and the context is ready for use.

Listeners may use this event to perform actions once the application is fully bootstrapped, such as triggering cache population, running scheduled tasks, or initializing external services.


Example:

class StartupInitializer implements ApplicationListener<ContextRefreshedEvent> {
  @override
  void onApplicationEvent(ContextRefreshedEvent event) {
    print("Context has been refreshed: ${event.getSource()}");
  }
}

This is usually the first lifecycle event emitted by the framework during startup.

Implementation

ContextRefreshedEvent.withClock(ApplicationContext source, DateTime Function() clock) : super.withClock(source, clock);