Annotation Type Shutdown


  • @Target(METHOD)
    @Retention(RUNTIME)
    public @interface Shutdown
    This annotation is used to mark a business method of a CDI bean that should be executed during application shutdown. The annotated method must be non-private and non-static and declare no arguments.

    The behavior is similar to a declaration of a ShutdownEvent observer. In fact, a synthetic observer of the ShutdownEvent is generated for each occurence of this annotation. Within the observer, the contextual instance of a bean is obtained first, and then the method is invoked.

    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 after the method is invoked for Dependent beans.

    The following examples are functionally equivalent.

     @ApplicationScoped
     class Bean1 {
         void onShutdown(@Observes ShutdownEvent event) {
             // place the logic here
         }
     }
    
     @ApplicationScoped
     class Bean2 {
    
         @Shutdown
         void shutdown() {
             // place the logic here
         }
     }
     
    See Also:
    ShutdownEvent
    • 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