-
@Documented @ApplicationScoped @Eager @Stereotype @Retention(RUNTIME) @Target(TYPE) public @interface Startup
Stereo type that designates a bean as an eagerly instantiated bean with application scope. Watch out with IDE autocomplete on import that you don't accidentally import EJB's one.
import org.omnifaces.cdi.Startup; @Startup public class MyStartupBean {}
In effect, this annotation does exactly the same as:
import jakarta.enterprise.context.ApplicationScoped; import org.omnifaces.cdi.Eager; @Eager @ApplicationScoped public class MyStartupBean {}
This bean type effectively functions as a CDI based startup listener for the web application.
Note that Java EE thus also provides the
jakarta.ejb.Startup
andjakarta.ejb.Singleton
annotations which together provide similar functionality, but it requires an EJB dependency (which may not be applicable on e.g. Tomcat+Weld) and it will result in the bean annotated with these annotations to become an EJB session bean (with automatic transaction management and automatic locking which you might need to turn off with yet more additionaljakarta.ejb.TransactionAttribute
andjakarta.ejb.Lock
annotations if these are not appropriate for some situation).- Since:
- 1.8
- Author:
- Arjan Tijms