Package io.quarkus.runtime
Annotation Type Startup
-
@Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) public @interface Startup
This annotation can be used to initialize a CDI bean at application startup:- If a bean class is annotated then a contextual instance is created and the
PostConstruct
callbacks are invoked. - If a producer method is annotated then a contextual instance is created, i.e. the producer method is invoked.
- If a producer field is annotated then a contextual instance is created, i.e. the producer field is read.
- If a non-static non-producer no-args method of a bean class is annotated then a contextual instance is created, the lifecycle callbacks are invoked and finally the method itself is invoked.
The behavior is similar to a declaration of a
StartupEvent
observer. In fact, a synthetic observer of theStartupEvent
is generated for each occurence of this annotation.Furthermore,
value()
can be used to specify the priority of the generated observer method and thus affects observers ordering.The contextual instance is destroyed immediately afterwards for
Dependent
beans.The following examples are functionally equivalent.
@ApplicationScoped class Bean1 { void onStart(@Observes StartupEvent event) { // place the logic here } } @Startup @ApplicationScoped class Bean2 { @PostConstruct void init() { // place the logic here } } @ApplicationScoped class Bean3 { @Startup void init() { // place the logic here } }
- See Also:
StartupEvent
- If a bean class is annotated then a contextual instance is created and the
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description int
value
-