JSF Named Bean, Eager application scoped (aka @ManagedBean(eager=true) )
Asked Answered
B

1

6

Is there any way to initialize Named Bean annotaded by javax.inject.Named/javax.enterprise.context.ApplicationScoped like @ManagedBean(eager=true) from javax.faces package?

@Named
@ApplicationScoped
public Mail() { ... }

I want to load this class when application starts, not when webapplication refers to this bean.

ps. JSF 2.1
Bean Injected by Glassfish 3.1

Beachhead answered 19/10, 2011 at 22:27 Comment(0)
D
3

You can create a CDI extension that has the @Observes AfterBeanDiscovery parameter on one of his methods. There you can instantiate the bean and thus initialize it when the container starts up. CODI has made those things easier for you, see https://cwiki.apache.org/confluence/display/EXTCDI/Core+Usage#CoreUsage-Startup

Democrat answered 26/10, 2011 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.