0

I have a JSF Application and want to use websockets to send messages to the webclient.

On the server side I'm executing some long-running asyn tasks, I perform it using the @Asynchronous annotation

    @Asynchronous
public void doLongRunningTasks(){...}

At some point, during the async process, I would like to send a Message to the client using a WebSocket and a PushContext. I know, I can inject the pushContext to a CDI Bean, doing something like

    @Named @ViewScoped public class
MsgBackingBean implements Serializable {

@Inject @Push private PushContext pushContext;

Now my problem: how can I access the MsgBackingBean from my async task due to the fact that I dont have a valid FacesContext? (FacesContext.getCurrentInstance() is null). Usually I programmatically instantiate my beans in this way:

FacesContext.getCurrentInstance().getApplication().evaluateExpressionGet(fc, "#{msgBackingBean}", MsgBackingBean.class);
Neo
  • 1,337
  • 4
  • 21
  • 50

0 Answers0