users@glassfish.java.net

Re: Using EJBs in CometHandler (GlassFish 2 UR2)

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 18 Jul 2008 11:39:13 -0400

Salut,

glassfish_at_javadesktop.org wrote:
>> It depends where you are creating your CometHandler.
>> If you creates it inside a Servlet, then you can probably "attach" it
>> using the CometHandler.attach().
>
> Yes, it's created in the servlet. Btw, I haven't understood the CometHandler.attach() method, or the need for it. At least I haven't found a use case for it yet. From the servlet, you can pass resources directly in the CometHandler constructor, because you create the CometHandler yourself anyway. The notifiers can pass data, too, so when do you need it?

Hahahahaha for a moment I was ready to agree, but ... Let's say you are
inside an EJB and you do:

CometContext ctx = CometEngine.getEngine().getCometContext("blabla");
CometHandler handler = ctx.getCometHandler(...);
handle.attach(myEbjObjectOrWhateverObject);

....

It gives you a unified way to pass object to the handler without the
needs to downcast the handler.


>
>>> Is it valid to just use the EJBs objects from the servlet?
>> Yes it should.
> I'll try. Although I guess the safest way to do it is to do a JNDI look up each time the onEvent Method is called (that's where I need the EJBs).

Is the JNDI lookup performance good? Long time I played with such call,
but if they cost nothing, then I agree this is the way to go.
>
>
>>> Injection in CometHandler would be nice...
>> Agree...at the time I wrote the Comet stuff, I don't
>> think the GlassFish
>> team would have let me add Injection ;-) Now that
>> Comet is more an dmore
>> used, for sure this is on the radar. I'm not ready
>> yet to push the
>> project on the spotlight, but Atmosphere.dev.java.net
>> is the Grizzly
>> Comet 2.0, and that one will support Injection.
>
> Nice, looking forward to it. Also, I hope there will be a standard (JSR/JEE) way to do stuff like at some point (that would be Servlets 3.1??).

I hope too. The lack of asynch I/O and API to filter/aggregate/throttle
  "pushed messaged" will makes hard to write Comet based application
that are portable, unless you use Atmosphere, which I doubt every
framework will support. Hence throttling push will be different when
using Jetty/Tomcat or GlassFish....hopefully not after Servlet 3.1 :-)

A+

--Jeanfrancois


>
>> Hope that help.
> Definitely. Thanks for your and ksak's help and explanations!
>
> Markus
> [Message sent by forum member 'markusoj' (markusoj)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287515
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>