You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "John D. Ament (JIRA)" <ji...@apache.org> on 2016/12/29 15:03:58 UTC

[jira] [Commented] (OWB-1164) Third Party Beans do not include Any qualifier if not included in bean impl

    [ https://issues.apache.org/jira/browse/OWB-1164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15785470#comment-15785470 ] 

John D. Ament commented on OWB-1164:
------------------------------------

[~rmannibucau] I see you made some changes on top of my patch.  There is one gotcha now.  If I change my bean to use this:

{code:java}
            @Override
            public Set<Annotation> getQualifiers()
            {
                Set<Annotation> qualifiers = new HashSet<>();
                qualifiers.add(new AnyLiteral());
                return qualifiers;
            }
{code}

Where {{AnyLiteral}} is defined as:

{code:java}
    public static class AnyLiteral implements Any
    {
        @Override
        public Class<? extends Annotation> annotationType() {
            return Any.class;
        }
    }
{code}

I'll point out that the use of {{AnnotationLiteral}} is meant as a convenience.  OWB and Weld both support direct annotation subclassing like I used here.  With your logic in place, then the bean ends up with two any qualifiers, which is strictly prohibited in CDI 1.2.  Using this logic gives some of the clean up you did but retains the check for classes.

{code:java}
    private Set<Annotation> calculateQualifiers(final BeanAttributes<T> beanAttributes)
    {
        final Set<Annotation> originalQualifiers = beanAttributes.getQualifiers() == null ?
                Collections.<Annotation>emptySet() : beanAttributes.getQualifiers();
        for(Annotation a : originalQualifiers)
        {
            if(a instanceof Any)
            {
                return originalQualifiers;
            }
        }
        final Set<Annotation> newQualifiers = new HashSet<>(originalQualifiers);
        newQualifiers.add(AnyLiteral.INSTANCE);
        return newQualifiers;
    }
{code}

> Third Party Beans do not include Any qualifier if not included in bean impl
> ---------------------------------------------------------------------------
>
>                 Key: OWB-1164
>                 URL: https://issues.apache.org/jira/browse/OWB-1164
>             Project: OpenWebBeans
>          Issue Type: Bug
>    Affects Versions: 1.7.0
>            Reporter: John D. Ament
>             Fix For: 1.7.1
>
>         Attachments: 0001-OWB-1164-Introduce-ThirdpartyBeanAttributes-to-calcu.patch
>
>
> Section 2.3.1 of CDI 1.2 spec indicates that custom beans should include the any qualifier even if not specified by the bean impl.  OWB does not honor this, instead only the original qualifiers are included in the bean.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)