1
我有CDI事件來通知我的JSF應用程序EJB進程的進度。當一切都是同步時,代碼工作正常。@ @detand bean中的@Asynchronous CDI Events和@Observes方法
@Stateless
public class MySessionBean implements Serializable {
@Inject
@ProcessEvent
Event<ProcessEvent> processEvent; // Also tried to use BeanManager
@Asynchronous // This annotation breaks my code
public void runLongProcess() {
processEvent.fire(new ProcessEvent());
}
}
。
@Named
@ViewScoped
public class ManagedBean implements Serializable {
@EJB
MySessionBean sessionBean;
public void runProcess() {
sessionBean.runLongProcess();
}
@Asynchronous // This annotation doesn't work
public void onEvent(@Observes @ProcessEvent ProcessEvent event){
LOGGER.log(Level.INFO, "Event was received"); // Never called
}
}
如果我在runLongProcess()
使用@Asychronous
註釋時,JSF @Observer
方法不會被調用。
如何實現此功能?
JSF 2.2 Glassfish的3.1 JEE 7 爪哇8個 Omnifaces 2.3