users@grizzly.java.net

Re: CometContext.addCometHandler returns redundant info.

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 14 Oct 2008 21:32:40 -0400

Salut,

gustav trede wrote:
>
> int CometContext.addCometHandler(CometHandler handler)
> returns the comethandlers hashcode, how come ?

yes that was a decision I took almost 3 years ago. At that time I was
returning the hashCode but I was planning to return a unique identifier.
The idea here is to avoid having to keep a reference to your
CometHandler, but use this unique id. Later you can always re-use that
ID to notify directly a single client and not the entire group.


>
> the hashcode is known by the calling context.
> its redundant information.

But how can you get that information from your Servlet?

>
> what would be of use is to know the actual status of the method, did the
> add of our comethandler work or not.
> returning a boolean stating the status of the handlers.putIfAbsent does
> bring extra knowledge.

Ya, that could be an idea. But how a Servlet can notify a single
CometHandler? As an example, let's say a moderator for a chat
application logs in. As the moment he logs in, you want to store its ID
and re-use that ID to push data to it using

notify(Object,CometEvent,ID);

I guess with your proposal you would like to support:

notify(Object,CometEvent,CometHandler)

right? Let me thing of it. I do agree it will makes the API cleaner.


>
> It can be used to check for logedin client for example.
> now i must use en extra external hasmap just for this.

You can always call CometContext.isActive(CometHandler) to detect that
scenario.


>
> the fact that the comethandlers.oninterrupt is to remove itself from
> the cometcontext has nothing to do with the need for status of this
> operation.

What do you means here? When onInterrupt() is invoked, under the hood
the CometHandler is always removed. Did I misunderstood your questions?


>
> this is not a major problem , cause its possible to workaround.
> its to put it mildly, just looks bad when its useless information being
> returned where we could have something meaningsfull.

Agree. Let's work a a better solution.

A+ and thanks for the feedback.

-- Jeanfrancois


>
> is it ok i change this ?.
>
>
> regards
> gustav trede
>
>
>
>
>
>
>
>
>