[cdi-dev] New Servlet related scope - @UpgradeScoped (?)
arjan.tijms at gmail.com
Mon Dec 8 10:34:00 EST 2014
On Mon, Dec 8, 2014 at 3:50 PM, Pavel Bucek <pavel.bucek at oracle.com> wrote:
>> 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.
No, but the idea is that if Servlet would make use of CDI, then there
still would be no cross-references.
If the @UpgradeScoped would be in Servlet, then it could reference
things in either Servlet (=same layer) or in CDI (one layer lower).
In that case, independent of whether any scope would move from CDI to
Servlet, or whether those scopes will stay in CDI, there will be no
> So, from my point of view, Servlet DOES NOT depend on CDI.
It doesn't, but who ever said that it does at the moment?
>> 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
Well, it defines when the scope should be active for each spec, but
what I meant is that the actual implementation of what the scope means
is in the other spec.
E.g. @RequestScope says it's active:
"during any remote method invocation of any EJB"
Naturally, what the time during a "remote method invocation of any
EJB" is, is defined in the EJB spec. CDI just says this scope should
match that, but it doesn't say what an EJB is, and what a "remote
method invocation" exactly is.
Eventually it's an architectural decision; should CDI have knowledge
of all other specs and depend on events or hooks in those specs to do
what I needs to do, OR should CDI be more about a lower level set of
primitive functionality that is used by all other specs?
We now unfortunately have both situations.
JSF has scopes like @ViewScoped and @FlowScoped that USE CDI. JSF will
get producers for several artefacts that USE CDI. CDI in those cases
does not know JSF.
JTA has an interceptor @Transactional that USES CDI. In this case, CDI
does not know JTA.
On the other hand, CDI has scopes like @RequestScoped that references
Servlet, Web Services, EJB and JMS. Here, Servlet, Web Services etc do
not know CDI.
CDI also has producers for several types like HttpServletRequest
(Servlet), Principal (technically JASPIC but can also be Servlet
proprietary) and UserTransaction (JTA). Here, Servlet, JASPIC and JTA
do not know CDI.
Especially for the producers it seems rather random of when it appears
in CDI, and when it appears in the spec that owns the produced
artefacts. As mentioned, the 3 scopes in CDI are somewhat more
complicated as at least two of them are broadly applicable. Should CDI
continue to define them, or should CDI give a very general
description, with the more specific description being given by each
spec itself? I don't really know what's best there.
> 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 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,
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> 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.
More information about the cdi-dev