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

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

The newest version!
package io.quarkus.runtime;

import static java.lang.annotation.ElementType.METHOD;
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 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 {@link ShutdownEvent} observer. In fact, a synthetic observer of the * {@link 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, {@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 onShutdown(@Observes ShutdownEvent event) {
 *         // place the logic here
 *     }
 * }
 *
 * @ApplicationScoped
 * class Bean2 {
 *
 *     @Shutdown
 *     void shutdown() {
 *         // place the logic here
 *     }
 * }
 * 
* * @see ShutdownEvent */ @Target(METHOD) @Retention(RUNTIME) public @interface Shutdown { /** * * @return the priority * @see jakarta.annotation.Priority */ int value() default ObserverMethod.DEFAULT_PRIORITY; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy