CDI ile JSF'de, observeinitializationapplication scope.
@Named
@ApplicationScoped
public class App {
public void startup(@Observes @Initialized(ApplicationScoped.class) Object context) {
// ...
}
public void shutdown(@Observes @Destroyed(ApplicationScoped.class) Object context) {
// ...
}
}
elinde OmniFaces sahip bu @Eager
ile basitleştirilmiş olabilir.
now deprecated
javax.faces.bean
ek açıklama MTU 2.2- olarak
@Named
@Eager
@ApplicationScoped
public class App {
@PostConstruct
public void startup() {
// ...
}
@PreDestroy
public void shutdown() {
// ...
}
}
başlatılır eagerly bir application scopedmanaged bean kullanımı.
@ManagedBean(eager=true)
@ApplicationScoped
public class App {
@PostConstruct
public void startup() {
// ...
}
@PreDestroy
public void shutdown() {
// ...
}
}
@ManagedBean (eager = true) 'ı denediniz mi? CDI (@ManagedBean yerine @Named) kullanıyorsanız, bu gibi bir şeyle "Gözlemleme" uygulama başlatmanız gerekir .. 'public void init (@Observes @ Initialized WebApplication webUygulama) {//bir şey yapın} ' (aslında bunu glassfish'te denemedim, jBoss AS 7'de kullandım ve diğer sunucularda bazı yapılandırmalara gereksinim duyabiliyorsunuz ... [this] (http://stackoverflow.com/) sorular/7347516/startup-pojo-on-a-kaynak-dikiş3-uygulama) ... – FMQ