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. The behavior is similar to a declaration of an observer of the StartupEvent - a contextual instance is created and lifecycle callbacks (such as PostConstruct) are invoked. In fact, a synthetic observer of the StartupEvent is generated for each bean annotated with this annotation. Furthermore, value() can be used to specify the priority of the generated observer method and thus affect 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 {
     }
     
    See Also:
    StartupEvent
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      int value  
    • Element Detail

      • value

        int value
        Returns:
        the priority
        See Also:
        Priority
        Default:
        2500