--
You received this message because you are subscribed to the Google Groups "MVC 1.0 Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsr371-users...@googlegroups.com.
To post to this group, send email to jsr371...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsr371-users/CAEXeC6znCK55oTqiq2d3ML%2BbXzj-0zefsjqfxPT2%3DGC-KiZoPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Java Champion, JCP EC/EG Member, EE4J PMC, JUG Leader
To view this discussion on the web visit https://groups.google.com/d/msgid/jsr371-users/CAOAQAPrzLb6sQR1gAN-rJpYMdaFc%3D8D%3Dq6Pf8A-NuT2Skw4-iQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsr371-users/CAOAQAPrzLb6sQR1gAN-rJpYMdaFc%3D8D%3Dq6Pf8A-NuT2Skw4-iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
With CDI enabled, what the spec states should be the default behavior on all JAX-RS implementations (whether it actually is, I don’t know for sure :). Per-request/@RequestScoped is the default scope in JAX-RS for resource classes.
I believe the @Dependent default scope only makes sense while injecting a bean in the context of another CDI bean, which is not the case for resource classes that are instantiated by the JAX-RS/MVC implementation.
On Apr 9, 2018, at 2:21 PM, Christian Kaltepoth <chri...@kaltepoth.de> wrote:Hi Santiago,thanks a lot for sharing your thoughts on this. See my reply inline.With CDI enabled, what the spec states should be the default behavior on all JAX-RS implementations (whether it actually is, I don’t know for sure :). Per-request/@RequestScoped is the default scope in JAX-RS for resource classes.That's not entirely correct. I agree that the JAX-RS spec states that non-CDI resources should be created per request. No doubt about that.
However, the JAX-RS spec doesn't say anything about the required scope if the resource is a CDI bean. So the default scope for CDI applies, which is @Dependent. I just checked this on Glassfish 5. CDI resources are dependent-scoped if no other scope annotation is added to the resource. If the default scope for CDI-based JAX-RS resources should be @RequestScoped, the JAX-RS implementation would need to change that using a CDI extension, but that doesn't seem to be the case.I believe the @Dependent default scope only makes sense while injecting a bean in the context of another CDI bean, which is not the case for resource classes that are instantiated by the JAX-RS/MVC implementation.I agree. However, my guess is that JAX-RS implementations typically lookup the resource from the CDI container once and then use this instance thought the full request processing lifecycle. In this case the resource will be created once and it will behave just like a @RequestScoped bean, although it is in fact @Dependent scoped.
The spec does not make that distinction, it just says that resource classes by default should be one per request. That should apply to CDI beans as well.
@Dependent with respect to what? If w.r.t to a @RequestScope bean, it would be fine.