el-next@uel.java.net

Re: Namespaced bases

From: Kin-man Chung <kinman.chung_at_oracle.com>
Date: Wed, 28 Apr 2010 10:40:33 -0700

Sorry for the late reply. I have more thoughts on this.

On 04/12/10 03:56, Pete Muir wrote:
> On 9 Apr 2010, at 19:11, Kin-man Chung wrote:
>
>
>> On 04/09/10 06:47, Pete Muir wrote:
>>
>>> The CDI spec calls for namespaced bean names (see section 2.5). It says
>>>
>>> "A bean may have a bean EL name. A bean with an EL name may be referred to by its name in Unified EL expressions. A valid bean EL name is a period-separated list of valid EL identifiers.
>>>
>>> The following strings are valid EL names:
>>>
>>> * org.mydomain.myapp.settings
>>> * orderManager"
>>>
>>>
>> Just need to make sure I understand, and showing my ignorance about CDI:
>>
>> The expression #{org.mydomain.myapp.settings.standard} actually means getting the property "standard" from the bean
>>
>> org.mydomain.myapp.settings, right?
>>
> Exactly.
>
>
>> How can this work with the current EL? Wouldn't the expression be parsed as getting the bean "org" and then get its property "mydomain", and then its property "myapp" etc?
>>
> We know up front (at deployment time) all bean names (and their namespaces) in a CDI module. Before checking if the property matches a bean, we check if the property matches the root of a namespace (and the base is null). If it does we return a Namespace object, otherwise we try to return the bean or say we can't resolve anything.
>
So the root of a namespace takes precedence over a bean name? Would it
be OK if we check a match for a bean first?

If we do that, then even if we don't know all the namespaces up front,
if it is not a bean, we'll return a Nanmspace object, meaning that it
may be the root of a namspace. When we have all the pieces of the
namespace at the end, we can check for its existence.
> Once we have resolved a root namespace, we get passed a base. If the base is a Namespace, we can then inspect the possible nodes of the namespace that it can have. If one matches, we return that Namespace object. Otherwise we try to resolve a bean (if this fails we say we can't resolve anything). And so on.
>
> This works reasonably well (and quickly) as we know the tree of namespaces up front, it wouldn't work so well if we didn't have this info...
>
This scheme works at expression evaluation time. If we can have a way
to identify namespaces at parse time, it would simpler and more
efficient. We'll need to tell EL about all the namespaces, I'll think
about this more.

You seem to imply that in CDI, all bean names are known at deployment
time, and have the life time of an application. Is this true? Can
beans (including those with namespaces) be created and destroyed in
between EL expressions? The reason I ask is that if we cannot determine
the existence of a bean until execution time, we probably cannot do
namespace resolution at parse time.

Also, would it be useful to be able to "import" namespace so that names
can be used without the namespaces?

-Kin-man
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: el-next-unsubscribe_at_uel.dev.java.net
> For additional commands, e-mail: el-next-help_at_uel.dev.java.net
>
>