users@grizzly.java.net

CometContext as class variable

From: Eric Luong <eluong_at_ualberta.ca>
Date: Wed, 20 Jul 2011 14:12:37 -0600

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