users@glassfish.java.net

Re: [v3] Comet/Bayeux available in GlassFish v3

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 25 Apr 2008 10:18:24 -0400

Salut,

we have a new users list for Comet and Web related technologies. I'm
cc-ing them :-)...and a soon a project called atmosphere.dev.java.net :-)

glassfish_at_javadesktop.org wrote:
> I am currently proposing Architecture based on Comet on Glassfish for an enterprise application.

Cool.


  One of the nice feature in GF is Comet. I looked at few comet samples
like chat, echo etc on GF. My question how can I expose changes in other
enterprise components, for example, ejb3.0 to be pushed to the client
which uses Dojo cometd?

 From a non web component, there is two ways to interact with a
CometContext:

(1) Pushing data from your external component (like an ejb).

 From you external component, get a reference to the CometContext you
are interested for. For example, you can have that code snippet inside
your ejb:

     CometContext ctx = CometEngine.getEngine().getCometContext("foo");
     ctx.notify(...some data from you ejb...);

By calling notify(), all CometHandler registered to the CometContext
will receive the data. Hence, all web client will be updated from/by
your ejb.

(2) Register a CometHandler to be notified when push operations happens.
As an example, from your ejb you can do:

     CometContext ctx = CometEngine.getEngine().getCometContext("foo");
     ctx.addCometHandler(this); //assuming your ejb implements CometHandler

Now every time data is pushed, you ejb will be notified.

<shameless-plug>
I will give a demo of a database that updates web clients (and clients
that update the db using comet) at CommunityOne if you can come:

http://www28.cplancom/cc197/session_details.jsp?isid=297346&ilocation_id=197-1&ilanguage=english

It does (1) and (2) :-)
</shameless- plug>


> I did not find any extension point in com.sun.grizzly.cometd.servlet.CometdServlet! Is there any other way which I missed? I read through most of your blogs but not able to find an answer for the above question. Basically I am looking for integration point using which I can hook messages from other entity componets which detect the data to be pushed to the client.

Something Jetty have and we don't right now is a way to send json/bayeux
messages from an external component like that:

http://cometdaily.com/2008/04/17/svnsearch-adds-real-time-updates/

We are working on it, but right now if you are planning to use
cometd/bayeux, just register your CometHandler to:

     CometContext ctx = CometEngine.getEngine().getCometContext("/cometd");
     ctx.addCometHandler(this);

This company:

http://web.mac.com/altmobile/altmobile_blog/ALT_Mobile_Blog/Entries/2008/3/21_Announcing_XML_Studio_v7.3.html

is using this approch for it product and it seems to work fine :-)

Hopefully the above will help :-)

Thanks!

-- Jeanfrancois


>
> Please guide me on this. Expecting reply.
>
> Thanks in Advance,
> Senthilkumar.
> [Message sent by forum member 'sendtopms' (sendtopms)]
>
> http://forums.java.net/jive/thread.jspa?messageID=271139
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>