[cdi-dev] New Servlet related scope - @UpgradeScoped (?)

arjan tijms arjan.tijms at gmail.com
Fri Dec 5 17:02:43 EST 2014


Hi,

On Friday, December 5, 2014, Pavel Bucek <pavel.bucek at oracle.com> wrote:

> please see inline.
>
> On 04/12/14 10:04, Martin Kouba wrote:
> > Dne 4.12.2014 v 09:28 Pavel Bucek napsal(a):
> >> Hello Arjan,
> >>
> >> On 03/12/14 19:44, arjan tijms wrote:
> >>> Hi,
> >>>
> >>> On Wednesday, December 3, 2014, Pavel Bucek <pavel.bucek at oracle.com
> <javascript:;>
> >>> <mailto:pavel.bucek at oracle.com <javascript:;>>> wrote:
> >>>
> >>>      Hi all,
> >>>
> >>>      I'm trying to figure out how to solve issue in JSR 356 - Java API
> for
> >>>      WebSocket, related to CDI scope usable from WebSocket endpoints.
> >>>      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 scope,
> >>> 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 similar
> >> dependency just because of new scope.
> > That's a good point. However, I don't think it's a good path to follow.
> > 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 areas
> > and doesn't always provide a powerful enough SPI. Even now there are
> > technical issues with similar requirements (e.g. @RequestScoped during
> > AsyncListener invocations). I'm not so sure about HttpUpgradeHandler
> > though...
>
> And what if the @UpgradeScoped definition would need to state something
> like "this scope is part of @ApplicationScoped"? That would result even
> 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?



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

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

Kind regards,
Arjan Tijms


>
> Con somebody suggest what should I do next? I can file an issue against
> CDI spec and even against Servlet spec, but my feeling is that it might
> 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,
> Pavel
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org <javascript:;>
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> 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...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20141205/203b44c8/attachment.html 


More information about the cdi-dev mailing list