@@ -190,6 +190,7 @@ A bean represented by a class, producer method or field annotated with `@Startup
190190----
191191package org.acme.lifecycle;
192192
193+ import io.quarkus.runtime.Startup;
193194import jakarta.enterprise.context.ApplicationScoped;
194195
195196@Startup // <1>
@@ -210,6 +211,57 @@ NOTE: `@Dependent` beans are destroyed immediately afterwards to follow the beha
210211
211212TIP: If a class is annotated with `@Startup` but with no scope annotation then `@ApplicationScoped` is added automatically.
212213
214+ The `@Startup` annotation can be also declared on a non-static non-producer no-args method:
215+
216+ [source,java]
217+ ----
218+ package org.acme.lifecycle;
219+
220+ import io.quarkus.runtime.Startup;
221+ import jakarta.enterprise.context.ApplicationScoped;
222+
223+ @ApplicationScoped
224+ public class EagerAppBean {
225+
226+ @Startup
227+ void init() { <1>
228+ doSomeCoolInit();
229+ }
230+ }
231+ ----
232+ <1> The bean is created and the `init()` method is invoked upon the contextual instance when the application starts.
233+
234+ [[shutdown_annotation]]
235+ === Using `@Shutdown` to execute a business method of a CDI bean during application shutdown
236+
237+ The `@io.quarkus.runtime.Shutdown` annotation is used to mark a business method of a CDI bean that should be executed during application shutdown.
238+ The annotated method must be non-private and non-static and declare no arguments.
239+ The behavior is similar to a declaration of a `ShutdownEvent` observer.
240+ The following examples are functionally equivalent.
241+
242+ [source,java]
243+ ----
244+ import io.quarkus.runtime.Shutdown;
245+ import io.quarkus.runtime.ShutdownEvent;
246+ import jakarta.enterprise.context.ApplicationScoped;
247+
248+ @ApplicationScoped
249+ class Bean1 {
250+ void onShutdown(@Observes ShutdownEvent event) {
251+ // place the logic here
252+ }
253+ }
254+
255+ @ApplicationScoped
256+ class Bean2 {
257+
258+ @Shutdown
259+ void shutdown() {
260+ // place the logic here
261+ }
262+ }
263+ ----
264+
213265== Package and run the application
214266
215267Run the application with:
0 commit comments