Hello,
Does it work? Meaning you were able to run the example in v2? Strange....it
> shouldn't work IMO.
yes it does work. the only change I have done is remove all the import
statements and add
import com.sun.enterprise.web.connector.grizzly.comet.*;
also added appserv-rt.jar to the project libraries.
>
> Just to make sure I understood properly. You want to push data from, let's
> say, an EJB or an external component, right? From an external components,
> you just need to do:
>
> CometContext ctx = CometEngine.getCometContext("YourContext");
> ctx.notify(....)
>
> The CometContext.notify will invoke the CometHandler.onEvent(), which most
> probably have a reference to the HttpServletResponse. From that object, you
> just need to flush what the external component/ejb have just pushed.
Well, I have done:
CometContext<?> context =
CometEngine.getEngine().getCometContext("/YBZ-war/tS");
try {
context.notify(null);
} catch (IOException ex) {
Logger.getLogger(TimerBean.class.getName()).log(Level.SEVERE, null, ex);
}
the above code is inside an ejb timer bean. Instead of using an atomic
integer, I have a long = System.currentTimeMillis() inside the
onEvent, this pushing the time as miliseconds at every iteration of the
timerBean.
I understand how the CometContext.notify invokes the CometHandler.onEvent(),
but I have not understood what you mean by 'from that object, you just need
to flush what the external component/ejb have just pushed.`
btw, what is the onIntterrupt method for? when does it get called. (upon
server stop?)
Best,
-C.B.