[cdi-dev] [JBoss JIRA] (CDI-132) Clarify which initial info AnnotatedType should contain

Jozef Hartinger (Commented) (JIRA) jira-events at lists.jboss.org
Tue Jan 10 11:20:12 EST 2012


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

Jozef Hartinger commented on CDI-132:
-------------------------------------

This is IMHO completely wrong. Having two classes:

{code:JAVA}
@Named
public class Foo {
}

public class Bar extends Foo {
}
{code}

we end up with two beans:
* Foo named "foo"
* Bar without name

Now suppose we add an extension that does not manipulate bean names at all. For instance:
{code:JAVA}
public class FooExtension implements Extension {

    public void wrap(@Observer ProcessAnnotatedType<Bar> event) {
        final AnnotatedType<Bar> bar = event.getAnnotatedType(); // bar.getAnnotations() contains Named
        event.setAnnotatedType(new ForwardingAnnotatedType(bar)); // just wrap, no change
    }
}
{code}

The container examines the annotated type provided by the extension --> getAnnotations() now contains Named. As a result, we end up with:
* Foo named "foo"
* Bar named "bar"

This is a side-effect of an extension that *does not actually change anything*.

                
> Clarify which initial info AnnotatedType should contain
> -------------------------------------------------------
>
>                 Key: CDI-132
>                 URL: https://issues.jboss.org/browse/CDI-132
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Portable Extensions
>            Reporter: Mark Struberg
>            Assignee: Pete Muir
>            Priority: Minor
>             Fix For: 1.1.EDR1
>
>
> The spec is not exactly clear about the initial content of AnnotatedType.
> When initially building the AnnotatedType (e.g. before handing it over to the Extensions) we need to pre-fill them with the info from the annotations from the classes.
> Should this AnnotatedType:
> 1.) contain no annotations from superclasses?
> 2.) contain all annotations from superclasses?
> 3.) contain @Inherited annotations from superclasses?
> I think the other questions already got cleared up in CDI-70:
> Should AnnotatedType contain derived public? protected? private? methods/fields from a superclass?
> Imo it should contain all information which would be available by manually parsing any annotations. In other words: it should be possible to completely modify or emulate annotations of a parsed type.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list