[jbosstools-issues] [JBoss JIRA] Issue Comment Edited: (JBIDE-9347) Show All Resolved Beans dialog

Alexey Kazakov (JIRA) jira-events at lists.jboss.org
Fri Jul 15 14:40:23 EDT 2011


    [ https://issues.jboss.org/browse/JBIDE-9347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614494#comment-12614494 ] 

Alexey Kazakov edited comment on JBIDE-9347 at 7/15/11 2:40 PM:
----------------------------------------------------------------

{quote}
?! Has this been random always ? I thought it was the one that would get injected ?
{quote}
I considered the case when we get an ambiguous injection. If CDI model resolved the injection successfully then we have the only resolved 
bean and we have an openOn *Open @Inject Bean <Type>* for that bean. We have it right now and we are not going to change it.
But if we try to resolve multiple eligible beans but get a few beans anyway then I suggest to show *Show All Resolved Beans* instead of a random bean from the set of the "resolved" beans.
{quote}
btw. is Assignable really the right term ? its both matching type and qualifiers right ?
{quote}
that's right. See the spec:
{quote}
*5.2. Typesafe resolution*
A bean is assignable to a given injection point if:
• The bean has a bean type that matches the required type. ...
• The bean has all the required qualifiers. ...
{quote}
{quote}
Beyond that if i'm following your explanation then what you want is to have Eligible and Assignable.
Where Eligibile is what you call Resolved.
{quote}
No, it's even more complicated.
A bean is eligible only if it is assignable *and* available. For example decorators and interceptors are not available for injections.
See the spec:  
{quote}
A bean is eligible for injection to a certain injection point if:
• it is available for injection in the module that contains the class that declares the injection point, and
• it is assignable to the injection point (using Section 5.2.3, “Assignability of raw and parameterized types”).
{quote}
But it's not an error to have multiple eligible beans for the injection until the ambiguity is not resolvable:
{quote}
An ambiguous dependency exists at an injection point when multiple beans are eligible for injection to the injection point.
...
When an ambiguous dependency exists, the container attempts to resolve the ambiguity. If any eligible beans are alternat-
ives, the container eliminates all eligible beans that are not alternatives, except for producer methods and fields of beans
that are alternatives. If there is exactly one bean remaining, the container will select this bean, and the ambiguous depend-
ency is called resolvable.
{quote}
So the set of beans that I call *resolved* is a set of eligible beans minus not alternatives, except for producers of alternatives. If there is no alternatives then the set of the eligible beans equals to the set of "resolved".

So we can describe the process of selecting the proper bean for the injection by the following steps:

# Collecting *available* beans. Decorators, Interceptors and some other beans are not available for injection.
# Collecting *assignable* beans: types, qualifiers should match. *<-- Show All Assignable Beans...*
# Collecting *eligible* beans: beans that are available && assignable.
# If there are multiple eligible beans and alternatives among them then eliminate not alternatives except for producers of alternatives:
-- Got the only bean? *<-- Open @Inject Bean <Type>*
-- Got more than one bean? *<-- Show All Resolved Beans...*

Maybe it's better to name this set as Unresolved beans... I'm really confused :(

      was (Author: akazakov):
    {quote}
?! Has this been random always ? I thought it was the one that would get injected ?
{quote}
I considered the case when we get an ambiguous injection. If CDI model resolved the injection successfully then we have the only resolved 
bean and we have an openOn *Open @Inject Bean <Type>* for that bean. We have it right now and we are not going to change it.
But if we try to resolve multiple eligible beans but get a few beans anyway then I suggest to show *Show All Resolved Beans* instead of a random bean from the set of the "resolved" beans.
{quote}
btw. is Assignable really the right term ? its both matching type and qualifiers right ?
{quote}
that's right. See the spec:
{quote}
*5.2. Typesafe resolution*
A bean is assignable to a given injection point if:
• The bean has a bean type that matches the required type. ...
• The bean has all the required qualifiers. ...
{quote}
{quote}
Beyond that if i'm following your explanation then what you want is to have Eligible and Assignable.
Where Eligibile is what you call Resolved.
{quote}
No, it's even more complicated.
A bean is eligible only if it is assignable *and* available. For example decorators and interceptors are not available for injections.
See the spec:  
{quote}
A bean is eligible for injection to a certain injection point if:
• it is available for injection in the module that contains the class that declares the injection point, and
• it is assignable to the injection point (using Section 5.2.3, “Assignability of raw and parameterized types”).
{quote}
But it's not an error to have multiple eligible beans for the injection until the ambiguity is not resolvable:
{quote}
An ambiguous dependency exists at an injection point when multiple beans are eligible for injection to the injection point.
...
When an ambiguous dependency exists, the container attempts to resolve the ambiguity. If any eligible beans are alternat-
ives, the container eliminates all eligible beans that are not alternatives, except for producer methods and fields of beans
that are alternatives. If there is exactly one bean remaining, the container will select this bean, and the ambiguous depend-
ency is called resolvable.
{quote}
So the set of beans that I call *resolved* is a set of eligible beans minus not alternatives, except for producers of alternatives. If there is no alternatives then the set of the eligible beans equals to the set of "resolved".

So we can describe the process of selecting the proper bean for the injection by the following steps:

# Collecting available beans. Decorators, Interceptors and some other beans are not available for injection.
# Collecting assignable beans. Types, qualifiers should match. *<-- Show All Assignable Beans...*
# Collecting eligible beans. Beans that are available && assignable.
# If there are multiple eligible beans and alternatives among them then eliminate not alternatives except producers of alternatives:
-- Got the only bean? *<-- Open @Inject Bean <Type>*
-- Got more than one bean? *<-- Show All Resolved Beans...*

Maybe it's better to name this set as Unresolved beans... I'm really confused :(
  
> Show All Resolved Beans dialog
> ------------------------------
>
>                 Key: JBIDE-9347
>                 URL: https://issues.jboss.org/browse/JBIDE-9347
>             Project: Tools (JBoss Tools)
>          Issue Type: Feature Request
>          Components: cdi (jsr-299)
>            Reporter: Alexey Kazakov
>            Assignee: Max Rydahl Andersen
>              Labels: new_and_noteworthy
>             Fix For: 3.3.0.M3
>
>         Attachments: Ambiguous.png, Assignable.png, OldAmbiguous.png, Resolved.png, TheOnlyOne.png
>
>
> *Let's see what we have right now.*
> If there is an ambiguous injection point and user Ctrl+Click on it then we show two hyperlinks. One of thous hyperlinks is *Show All Eligible Beans...* that is not quite accurate, btw. The the other one is *Open @Inject Bean <Type>* which opens a random bean from all the resolved beans. If we have more than one eligible bean than we try to resolve them. If we still have a few "resolved" beans then we mark an injection as ambiguous and our OpenOn dialog uses a random bean from this resolved set.
> !OldAmbiguous.png!
> *What I suggest to change.*
> First at all let's rename "Show All *Eligible* Beans..." to "Show All *Assignable* Beans..." since we show all the assignable beans (beans which match the type and the qualifiers) but not eligible (assignable & enabled). For instance a set of assignable beans includes decorators and interceptors.
> Then, in case of an ambiguous injection, I think we should suggest to show two sets of beans: *resolved* and *assignable* instead of *random bean from the resolved set* and *assignable*. It will look like the following dialog:
> !Ambiguous.png!
> Where *Show All Resolved Beans...* opens a dialog with all the beans which match the injection (if such a set had the only resolved bean then the injection wouldn't be ambiguous):
> !Resolved.png!
> And *Show All Assignable Beans...* which shows all the assignable beans (right now we have that dialog by "Show All Eligible Beans..." label):
> !Assignable.png!
> I'm not sure that *resolved* is good term for the dialog *Show All Resolved Beans...* since actually this is a list of beans that we got trying to resolve the eligible beans and failed to resolve it to the only bean. Any ideas how we can name such a set?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jbosstools-issues mailing list