OnContextLoaded constructor
const
OnContextLoaded()
Annotation to mark a method that should run when the application context has been loaded, but before it is fully refreshed.
This lifecycle hook is useful for modifying or inspecting the context immediately after it has been constructed, but before pods/services are refreshed and initialized.
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 {
@OnContextLoaded()
void inspectContext() {
print("Context has been loaded, inspecting pods...");
}
@OnContextLoaded()
void inspectContextWithContext(ConfigurableApplicationContext context) {
print("Context has been loaded, inspecting pods...");
}
}
Implementation
const OnContextLoaded();