dev@glassfish.java.net

Injection to HttpSessionBindingListener and HttpSessionActivationListener

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Thu, 20 Sep 2007 11:30:44 -0400

JavaEE Platform Spec states injection is supported in all web
application listeners, without listing all
the listener classes. Various Sun docs [1] list the following 7
listeners that support injection:

javax.servlet.ServletContextListener
javax.servlet.ServletContextAttributeListener
javax.servlet.ServletRequestListener
javax.servlet.ServletRequestAttributeListener
javax.servlet.http.HttpSessionListener
javax.servlet.http.HttpSessionAttributeListener
javax.servlet.http.HttpSessionBindingListener

Among the 7 listeners, HttpSessionBindingListener is different than the
other 6. It is implemented by
application types that are to be stored in session. An
HttpSessionBindingListener type is usually created
by application, not by the container. So it's hardly a
container-managed component.

Is injection really required by the spec, and supported in glassfish for
HttpSessionBindingListener?

Also missing from the above list is HttpSessionActivationListener, which
is similar to
HttpSessionBindingListener in that both interfaces are implemented by
interested
session attributes. I would image they should be treated the same for
injection purpose.

When I tried to inject resources into a HttpSessionBindingListener
class, it was silently ignored. The
same resources can be successfully injected into other 6 web event
listeners.

Did anyone get injections into HttpSessionBindingListener or
HttpSessionActivationListener
working?

 From implementation perspective, how does glassfish handle injections into
HttpSessionBindingListener and HttpSessionActivationListener?

[1]
http://java.sun.com/developer/technicalArticles/J2EE/injection/
http://java.sun.com/javaee/5/docs/tutorial/doc/bnaeo.html#bnaeu

Thanks,
-cheng