jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Re: [jsr372-experts mirror] Working towards Early Draft Review

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Thu, 13 Aug 2015 11:19:53 +0200

Hi,

On Thu, Aug 13, 2015 at 12:25 AM, Edward Burns <edward.burns_at_oracle.com> wrote:
>>>>>> On Thu, 30 Jul 2015 16:50:57 +0200, arjan tijms <arjan.tijms_at_gmail.com> said:
> Can you please reply with an explanation for why this feature is
> important? To me it just seems like "correctness" plumbing, but there
> has to be a more compelling reason than just that.

There are several reasons really.

If I'm not mistaken the discussion started with caching the result of
EL evaluation, where it was ultimately decided that not the actual
invocation of a property or even method was expensive, but the target
bean lookup.

Now CDI already has an EL resolver and a caching mechanism (it's the
scope the bean is in), and since CDI is so much used these days it was
thought to have received many optimisations here already and likely
will receive more. JSF would have to redo this and then keep doing it,
not automatically benefitting from whatever new optimisations a CDI
implementation puts in place.

Simultaneously there was a discussion to make a certain number of JSF
artefacts injectable. This is not only more convenient for the user,
but when CDI is used also comes with an array of extra features that
from JSF's point of view are "free". E.g. contextual proxies (so that
smaller scopes can be injected in larger scopes) and the ability for
users to provide alternatives/overrides using @Alternative/_at_Priority.

As it happens these 2 concepts (injection and EL resolving) are
unified in CDI via its Bean<T> concept, which we call "dynamic
producer" in the Mojarra implementation code since the term "Bean" is
a little ambiguous in JSF. E.g.

public class FacesContextProducer extends CdiProducer<FacesContext> {
    public FacesContextProducer() {
        super.name("facesContext")
             .scope(RequestScoped.class)
             .beanClassAndType(FacesContext.class)
             .create(e -> FacesContext.getCurrentInstance());
    }
}

This makes the FacesContext available for injection, and since a name
is provided it's simultaneously available in EL via #{facesContext}.

Hope this makes it more clear.

Kind regards,
Arjan Tijms




>
> Thanks,
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | 59 Business days til JavaOne 2015
> | 74 Business days til DOAG 2015