Hi Antonio,

I saw one thread about moving Servlet related scopes to servlet spec (I agree with that step!), but there was no clear conclusion stating that it will actually happen.

Just one correction - @UpgradeScoped belongs to Servlet spec; If you would want to introduce something into WebSocket spec, it would need to be something like @WebSocketSessionScoped; upgrade is defined in Servlet and if there is any scope derived from it, it should be there.

@ViewScoped/@FlowScoped are different - there are specific to JSF. @UpgradeScoped is specific to Servlet and WebSocket spec just depends on that.

Regards,
Pavel

On 04/12/14 10:17, Antonio Goncalves wrote:
Hi 

FYI we are hoping to have no Servlet related topics in the CDI 2.0 specification. The idea is for other specifications to use CDI to create their own scope (@ViewScoped/@FlowScoped in JSF, but also @TransactionScoped in JTA). Following this logic, the @UpgradeScoped would make sense in the WebSocket spec.

Antonio

On Thu, Dec 4, 2014 at 9:28 AM, Pavel Bucek <pavel.bucek@oracle.com> wrote:
Hello Arjan,

On 03/12/14 19:44, arjan tijms wrote:
Hi,

On Wednesday, December 3, 2014, Pavel Bucek <pavel.bucek@oracle.com> 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.

Thanks,
Pavel


_______________________________________________
cdi-dev mailing list
cdi-dev@lists.jboss.org
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.



--
Antonio Goncalves
Software architect, Java Champion and Pluralsight author

Web site | TwitterLinkedIn | Pluralsight | Paris JUG | Devoxx France