users@grizzly.java.net

Re: CometContext as class variable

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 21 Jul 2011 10:33:50 +0200

Hi Eric,

> Ah, apologies, I linked the wrong post. This is the one I meant:
>
> http://antwerkz.com/grizzly-2-0-and-comet/
>
> Another place where it's seen is in the hidden frame example in the
> Oracle documentation:
>
> http://download.oracle.com/docs/cd/E18930_01/html/821-2418/ggrgt.html#ggrgr
>
> On Wed, Jul 20, 2011 at 2:12 PM, Eric Luong <eluong_at_ualberta.ca
> <mailto:eluong_at_ualberta.ca>> wrote:
>
> Hello,
>
> I noticed that in many of the sample code snippets, the
> CometContext is retrieved locally within doGet and doPost, e.g. here:
>
> http://antwerkz.com/glassfish-ose-3-1-is-out-with-websocket-support-included/
>
> I am still unfamiliar with underpinnings of Grizzly/Glassfish and
> servlet programming in general so I am curious why this is done.
> I tried retrieving a CometContext in a servlet's init and keeping
> and using it as a class variable. It seemed to work just the
> same, but could it cause other problems that the local way
> avoids? The only thing I can think of is that using only the
> class variable could perhaps cause concurrency or scalability issues.
>
If it's your application and you know that context for the URL is not
going to be replaced/removed - you can retrieve it in the init() method.

Thanks.

WBR,
Alexey.

>
> Thank-you for your insight!
>
> Eric
>
>