[cdi-dev] Is it required to explicitly add @Any for custom beans?

Gunnar Morling gunnar at hibernate.org
Wed Feb 5 11:00:26 EST 2014


Ok, I've created https://issues.jboss.org/browse/CDI-419 to keep track of
it.

Thanks,

--Gunnar


2014/2/4 Pete Muir <pmuir at redhat.com>

> Agreed, we can tidy up the language here.
>
> On 4 Feb 2014, at 16:53, Gunnar Morling <gunnar at hibernate.org> wrote:
>
> > Hi Martin,
> >
> > 2014/2/4 Martin Kouba <mkouba at redhat.com>
> > Hi Gunnar,
> >
> > I believe it is required.
> >
> > See the spec section 11.1 The Bean interface:
> > "getTypes(), getQualifiers(), getScope(), getName() and getStereotypes()
> > must return the bean types, qualifiers, scope type, bean name and
> > stereotypes of the bean, as defined in Chapter 2"
> >
> > I think the sentence you're referencing is rather about class-based
> > beans, not custom beans.
> >
> > Yes, that's the question.
> >
> > It doesn't explicitly say it's about class-based beans only, so it can
> be perceived as applying to custom beans as well. Then I'd understand the
> "as defined in Chapter 2" from section 11.1 as "it's not required to
> explicitly return @Any".
> >
> > But it's not very clear.
> >
> > Right, some clarification would be nice. In my particular case I'll just
> add a literal for @Any, but it's easy to forget to do so when writing a PE,
> so it might be useful to require a CDI implementation to automatically add
> that qualifier for custom beans if missing.
> >
> > M
> >
> >
> > Dne 4.2.2014 09:54, Gunnar Morling napsal(a):
> > > Hi,
> > >
> > > I'm registering a custom Bean implementation using a portable
> extension.
> > > Injection of this bean using the @Any qualifier fails unless I
> > > explicitly add this qualifier in the getQualifiers() implementation of
> > > my bean.
> > >
> > > Now the spec says in 2.3.1:
> > >
> > >     "Every bean has the built-in qualifier @Any, even if it does not
> > > explicitly declare this qualifier [...]"
> > >
> > > Based on that, I had expected that I'm not required to add this
> > > qualifier to my custom bean implementation. Or am I misinterpreting the
> > > spec here?
> > >
> > > Thanks,
> > >
> > > --Gunnar
> > >
> > >
> > >
> > > _______________________________________________
> > > cdi-dev mailing list
> > > cdi-dev at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/cdi-dev
> > >
> >
> > _______________________________________________
> > cdi-dev mailing list
> > cdi-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/cdi-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20140205/cc4e168e/attachment.html 


More information about the cdi-dev mailing list