dev@glassfish.java.net

Re: Injection to HttpSessionBindingListener and HttpSessionActivationListener

From: <Jan.Luehe_at_Sun.COM>
Date: Fri, 21 Sep 2007 11:48:34 -0700

Hi Cheng,

Cheng Fang wrote:

> 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?


Looks like a bug in the spec to me.

I agree with you that neither HttpSessionBindingListener nor
HttpSessionActivationListener
instances are container-managed (they are instantiated by the app and
stored in the session),
and therefore, I don't see how they could be candidates for injection by
the container.

I don't think there are any TCKs for this (I don't see how there could
be), but I'm cc'ing Dianne
to confirm.


Jan


>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>