Salut,
Cam Bazz wrote:
>
> 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.*;
OK then you don't need to add anything under the ${glassfish.home}/lib
in that case.
>
> also added appserv-rt.jar to the project libraries.
Yes.
>
>
>
> 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.`
I means you flush what the ejb is sending via the CometContext.notify()
(sorry I was unclear).
So does it answer your original question?
>
> btw, what is the onIntterrupt method for? when does it get called. (upon
> server stop?)
When the client close the connection, the onInterrupt() method will be
called. That will gives you an opportunity to clean resource associated
with that connection.
Thanks
-- Jeanfrancois
>
> Best,
> -C.B.
>