[cdi-dev] New Servlet related scope - @UpgradeScoped (?)
pavel.bucek at oracle.com
Mon Dec 8 09:50:12 EST 2014
please see inline.
On 05/12/14 23:02, arjan tijms wrote:
> On Friday, December 5, 2014, Pavel Bucek <pavel.bucek at oracle.com
> <mailto:pavel.bucek at oracle.com>> wrote:
> On 04/12/14 10:04, Martin Kouba wrote:
> > Dne 4.12.2014 v 09:28 Pavel Bucek napsal(a):
> >> On 03/12/14 19:44, arjan tijms wrote:
> >>> On Wednesday, December 3, 2014, Pavel Bucek
> >>> I'm trying to figure out how to solve issue in JSR 356 -
> Java API for
> >>> WebSocket, related to CDI scope usable from WebSocket
> >>> Problem
> >>> is, that "standard" scopes do not apply, because there is no
> >>> @RequestScoped (http response is already sent),
> HttpSession does not
> >>> need to be created and the rest does not seem to be
> applicable, ...
> >>> I believe that CDI specification should define
> @UpgradeScoped, which
> >>> would cover usages of HttpUpgradeHandler from Servlet API.
> >>> (Similarly as
> >>> it does for @RequestScoped, @SessionScoped, ... )
> >>> Wouldn't it be a better option to have WebSocket define that
> >>> using CDI to implement it?
> >> That is one possibility, but @UpgradeScoped would be more
> general than
> >> just for WebSocket - it would apply for all HTTP/1.1+ Upgrade
> >> applications. In my eyes, it is something which was forgotten
> to do in
> >> Java EE 7 release, since HttpUpgradeHandler was introduced in it.
> >> Also please note, that other Servlet related scopes are already
> in CDI
> >> spec, so it seems like it belongs there more than anywhere
> else. This
> >> might have multiple reasons - for example, you can easily define
> >> relationship between @UpgradeScoped and others, already
> existing ones.
> >> In this sense, CDI specification now depends on Servlet API (it
> >> references some of the classes defined in it), but Servlet does
> not do
> >> that for CDI. I don't think that Servlet spec should introduce
> >> dependency just because of new scope.
> > That's a good point. However, I don't think it's a good path to
> > I mean if it were in CDI spec, CDI implementations would be
> required to
> > implement this. However, Servlet spec is not very clear in many
> > and doesn't always provide a powerful enough SPI. Even now there are
> > technical issues with similar requirements (e.g. @RequestScoped
> > AsyncListener invocations). I'm not so sure about HttpUpgradeHandler
> > though...
> And what if the @UpgradeScoped definition would need to state
> like "this scope is part of @ApplicationScoped"? That would result
> in more confusion and cross references CDI to Servlet and vice versa.
> I'm not so sure that would necessarily be confusing. If Servlet is
> "layered" on top of CDI, then a scope in Servlet could reference other
> things within the Servlet spec, or things in lower layers, which is
> CDI in this case.
> There would be no cross-references there, would there?
well.. I'm not the expert in Servlet nor CDI spec, but what I see in
Servlet is NOT related to CDI directly. Simple search does not include
any "RequestScoped" appearance. There is only brief reference to it in
chapter 15.5.15, but that refers only to Java EE 7 umbrella
specification definition. So, from my point of view, Servlet DOES NOT
depend on CDI.
On the other hand, CDI specification references directly to Servlet
classes/methods in multiple chapters: 3.8, 5.5.2, 5.5.3, 6.7.1, 6.7.2,
6.7.3, 6.7.4, ... .
Please note that I'm using last released versions of spec documents -
Servlet 3.1 and CDI 1.2.
> I could see this being part of Servlet spec only if all other
> "Servlet-related" scopes are there as well.
> Correct me if I'm wrong, but there's only one scope in CDI that at the
> moment exclusively references Servlet, and that's @SessionScoped.
> Both @RequestScoped and @ApplicationScoped have a (much) broader
> definition than being just a Servlet scope.
> I'm not entirely sure, but the way these 3 scopes are now set up may
> not exclude @SessionScoped being applied to other things as well.
Same for @UpgradeScoped - it might be applied to other things as well
(little bit far fetched from my side, I know - @SessionScoped is much
more general than @UpgradeScoped).
> The one problem may be that CDI here lists all other specs that give
> meaning to the scope. Even though it's just text and not an actual API
> dependency, this may not be entirely consistent (but how could it be
> done better?)
That is not exactly correct - CDI spec defines how these scopes should
be implemented - it *gives* the meaning to the scopes (at least in this
case) in other specifications (see my note about no @*Scoped references
in Servlet spec).
Please don't take this as "@UpgradeScoped" must be introduced and it
must be in CDI spec. I'm just trying to see where it should be and
currently I think it should be near other scope definitions. As I said,
I can start similar discussion with Servlet spec group, but it would be
nice to have some conclusion from here..
Thanks and regards,
> Kind regards,
> Arjan Tijms
> Con somebody suggest what should I do next? I can file an issue
> CDI spec and even against Servlet spec, but my feeling is that it
> be deferred on both issue trackers as "not in scope, it should be done
> somewhere else". I know I already asked, but - is there any discussion
> between CDI and Servlet spec leads about this topic?
> Thanks and regards,
> cdi-dev mailing list
> Note that for all code provided on this list, the provider
> licenses the code under the Apache License, Version 2
> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other
> ideas provided on this list, the provider waives all patent and
> other intellectual property rights inherent in such information.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cdi-dev