OnEnvironmentPrepared class final
Annotation to mark a method that should run when the application environment has been prepared, but before the context is loaded.
This is the earliest lifecycle hook in the startup sequence. It allows you to inspect or modify environment properties, configure logging, or validate profiles before the context is created.
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
ConfigurableEnvironment
orConfigurableBootstrapContext
. - Two-Args: The method should accept two arguments of types
ConfigurableEnvironment
andConfigurableBootstrapContext
.
Example
class MyApp {
@OnEnvironmentPrepared()
void setupEnvironment() {
print("Environment prepared, validating configuration...");
}
@OnEnvironmentPrepared()
void setupEnvironmentWithEnvironment(ConfigurableEnvironment environment) {
print("Environment prepared, validating configuration...");
}
@OnEnvironmentPrepared()
void setupEnvironmentWithEnvironmentAndBootstrapContext(ConfigurableEnvironment environment, ConfigurableBootstrapContext bootstrapContext) {
print("Environment prepared, validating configuration...");
}
@OnEnvironmentPrepared()
void setupEnvironmentWithBootstrapContext(ConfigurableBootstrapContext bootstrapContext) {
print("Environment prepared, validating configuration...");
}
}
- Annotations
-
- @Target.new({TargetKind.method})
Constructors
- OnEnvironmentPrepared()
-
Annotation to mark a method that should run when the application
environment has been prepared, but before the context is loaded.
const
Properties
- annotationType → Type
-
Returns the annotation _type of this annotation.
no setter
- hashCode → int
-
Returns a hash code consistent with equality definition.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
equals(
Object other) → bool -
Checks whether the given object is logically equivalent to this annotation.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation of this annotation.
inherited
Operators
-
operator ==(
Object other) → bool -
Checks if this annotation is equal to another object.
inherited