jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Should _at_SessionScoped Beans Allow Injection of Resources

From: Josh Juneau <juneau001_at_gmail.com>
Date: Sat, 4 Apr 2015 12:30:42 -0500

I am developing an example application to demonstrate the features of JSF
2.3. I've encountered what I would call an issue, a while back, as I was
unable to inject any of the Faces CDI resources into @SessionScoped beans,
unless I mark the injected resource(s) as transient. I have no problems
injecting them into @Dependent or @RequestScoped beans, of course. This is
obviously occurring because the producers are not passivation capable.

In my opinion, there are some cases where it makes sense to utilize a
@SessionScoped bean that contains injected resources...perhaps
@FacesContext, for issuing a FacesMessage. While we can certainly utilize
@RequestScoped beans that utilize @SessionScoped beans for management of
objects that need to stay within the session, that may be cumbersome under
some circumstances, and I can see the use case of allowing injection of
resources into @SessionScoped beans.

I wanted to bring this to the expert group to see if anyone else in the
group believes that we should allow injectable resources into
@SessionScoped beans, as I think it may promote ease of use in some
situations.

Thanks for your time, it is appreciated.

Josh Juneau
juneau001_at_gmail.com
http://jj-blogger.blogspot.com
https://www.apress.com/index.php/author/author/view/id/1866