users@grizzly.java.net

Re: CometContext as class variable

From: Ryan Lubke <ryan.lubke_at_oracle.com>
Date: Wed, 20 Jul 2011 21:22:46 -0700

On 7/20/11 1:20 PM, Eric Luong wrote:
> 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

The javadocs for CometContext indicate it can be shared:

"....
* A CometContext can be shared amongst Servlet of the same
* application, or globally across all deployed web applications.
...."


>
> 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.
>
> Thank-you for your insight!
>
> Eric
>
>