On Thu, Sep 19, 2013 at 11:28 AM, Mark Thomas <ma...@apache.org> wrote:

> On 19/09/2013 17:39, Nick Williams wrote:
> >
> > On Sep 19, 2013, at 11:32 AM, Jeremy Boynes wrote:
> >
>
> >> There's a clear model already without assumptions about SCI
> >> ordering: SCIs fire before SCLs, and SCLs can be ordered explicitly
> >> by web.xml. There are no ordering requirements for SCIs except that
> >> they are discovered per the delegation model. This change is
> >> changing that to load "container" SCIs firsts *even if the
> >> delegation model specifies application first.*
> >
> > Loading/discovering SCIs and invoking SCIs are not the same thing.
> > This change is spec compliant because it still loads/discovers SCIs
> > per the delegation model. The spec does NOT say that SCIs must be
> > ordered according to the delegation model (or even that they must be
> > ordered in any fashion at all).
>
> Exactly. I went back and checked the EG discussion that lead to the text
> in 8.2. It was solely concerned with loading - not execution order.


My point is is that this change changes that order (which is needed as it
was not actually right to start with). With it, SCIs defined by the
container are always loaded before SCIs defined by the application even if
the application jars precede the container jars in the classloader
delegation order (which they normally would). The algorithm above, however,
ensures that the delegation order is maintained.

As you say, the spec does not specify *any* order for invoking SCIs which
means any conforming SCI implementation cannot assume that it will be
invoked before or after any other. Listener ordering, however, is
determined by the effective web.xml created by merging the fragments and
the ordering rules for that are clearly defined by the spec (including that
they are invoked after all SCIs).

The original issue on the user list was that application code in a SCI was
accessing the ServletContext before it was fully initialized. This is an
application bug which it should fix. One way, as suggested, would be to
defer that work to an SCL that is guaranteed not to be invoked until the
ServletContext is fully initialized; it can do that by registering the SCL
in the SCI or by defining it in web.xml or a fragment if it needs to be
ordered relative to other SCLs.

--
Jeremy

Reply via email to