0

Is there any way to notify jsf/spring bean when aynchronous messages are received by a java program? Moreover, the java program is a Java BayeuxClient (Cometd) as a pojo. The program successfully receives messages on the meta channels and subscribed channels as shown below.

@Listener(Channel.META_CONNECT)
    public void metaConnect(Message message) {
    boolean connected = message.isSuccessful();
            ...
    }

@Subscription("/notification")
    public void subscribeUpdates(Message message) {

    String updates=message.getDataAsMap().toString()    
        .....   
    }

FacesContext is not available within these methods, even bean is annotated with(@Component @Scope("session") for jsf/spring integration. Beans cannot be injected as facesContext is not available. How can we inject jsf beans or notify spring bean from the above methods?

user2263197
  • 97
  • 1
  • 12

1 Answers1

0

Have a look at the CometD-Spring integration.

You can define your CometD services within a Spring configuration file (or annotate them), and wire the dependencies with the usual Spring mechanisms.

I don't recommend to access the FacesContext directly because this will bind you to the HTTP transport, and you won't be able to use the WebSocket transport, which will give you a performance boost.

I suggest that you refactor your messaging logic into POJOs that are transport agnostic that is, do not depend on classes like HttpServletRequest, HttpSession, FacesContext, etc.

sbordet
  • 16,856
  • 1
  • 50
  • 45
  • Thanks. I have to push two variables (Network Status and Synchronization Status) on web page.I was able to push using ICEfaces Ajax Push from faces Context. I can determine Network Status from message received on metaConnect method above. Network Status set to true will automatically kick off the Synchronization process after re-connect with remote Server.The local server will act as Java Bayeux Client. The problem is pushing network status and result of synchronization process to web-page. I have used Annotated Client-Side Service as Spring Bean and able to receive subscribed messages. – user2263197 Apr 10 '13 at 15:55