[cdi-dev] New Servlet related scope - @UpgradeScoped (?)
pavel.bucek at oracle.com
Mon Dec 8 11:12:52 EST 2014
On 08/12/14 16:34, arjan tijms wrote:
> 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?
it was meant as a reply to the discussion about cross references, which
would be introduced by adding reference to CDI to Servlet.
Based on our discussion, it seems like CDI should just declare generic
cases where @*Scoped should be used and the rest (Servlet related
definitions) should be somewhere else (Java EE umbrella? Servlet?). If
that would be that case, CDI could be clean and "independent".. (current
state almost implies CDI release when some of the referenced
class/method is changed/removed/deprecated/...).
>>> 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.
Thanks for this summary, that is really useful (specially for me, since
I really don't know that much about CDI :-) ).
It would be nice to have some feedback from Pete and/or Antione.
Thanks and regards,
More information about the cdi-dev