@Documented @ApplicationScoped @Eager @Stereotype @Retention(value=RUNTIME) @Target(value=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 javax.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 javax.ejb.Startup
and javax.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 additional javax.ejb.TransactionAttribute
and javax.ejb.Lock
annotations if these are
not appropriate for some situation).
Copyright © 2012–2020 OmniFaces. All rights reserved.