The FacesContext is HTTP request based and thus only available during the HTTP request processing and even then only when the request URL matches the url pattern of the FacesServlet. If you're not inside the thread which is executed by the server to process the HTTP request, then there's also no means of a FacesContext. In an EJB container there's totally no means of HTTP requests.
Technically, the only way to let EJB inform JSF about a new message is to let EJB fire a HTTP request on an URL matching the url pattern of the FacesServlet with the message as request parameter. You can use java.net.URLConnection
for this. JSF in turn can then do the Comet/HTTP push like stuff to update the view with the message the IceFaces way as you mentioned.
E.g.
URL url = new URL("http://example.com/context/poll.jsf?msg=" + URLEncoder(msg, "UTF-8"));
URLConenction connection = url.openConnection();
InputStream response = connection.getInputStream();
and a poll.jsf
which is attached to a backing bean like this:
@ManagedBean
public class Poll {
@ManagedProperty(value="#{param.msg}")
private String msg;
@PostConstruct
public void init() {
// Do something with msg.
}
public void setMsg(String msg) {
this.msg = msg;
}
}
Note: using JSF 2.0 annotations, but they ought to be self-explaining enough.