All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.runtime.Startup Maven / Gradle / Ivy

The newest version!
package io.quarkus.runtime;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.inject.spi.ObserverMethod;

/**
 * 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 {@link jakarta.annotation.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 {@link StartupEvent} observer. In fact, a synthetic observer of the * {@link StartupEvent} is generated for each occurence of this annotation. *

    * Furthermore, {@link #value()} can be used to specify the priority of the generated observer method and thus affects observers * ordering. *

    * The contextual instance is destroyed immediately after the method is invoked for {@link 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 StartupEvent */ @Target({ TYPE, METHOD, FIELD }) @Retention(RUNTIME) public @interface Startup { /** * * @return the priority * @see jakarta.annotation.Priority */ int value() default ObserverMethod.DEFAULT_PRIORITY; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy