On 18 Oct 2011, at 06:59, Rick Hightower wrote:
"Any class or package may be prevented from providing bean
definitions based on the availability of other classes by adding the @Requires annotation
on the class or package."
@Requires({Customer.class, Supplier.class}) public class Order { ...
}
Spring has something similar called @Required with some different behavior. But now that
I think on it... it is different enough....
I'd prefer explicit names for these annotations. @ExcludeFromCDI and @
ExcludeFromCDIIfMissing.
I know those are horrible names too. Not a big fan of @Veto and @Requires.
Hmm. Those names are not particularly consistent with the language style or meaning used
in CDI (for example, we never talk about CDI that way in the spec).
@Veto is consistent with the .veto() method in the SPI, which is why it was chosen.
@Requires we agonised over for a long time, but couldn't come up with anything better.
If anyone has a better idea, please speak :-)
How about @ExcludeAsSource, and it has an optional attribute called
requires that takes an array of class types?
I'm not sure this makes any sense, you aren't "excluded it as source"
(the class definition is still available), but vetoing the use of the class as a bean.
@Excludes could work (and is consistent with the CDI style), possibly with an attribute
called unlessAvailable (or something like that).
I really really hate @Veto and @Requires. I guess I should search the mail list and see
if I missed this conversation.
This was originally discussed on the seam or weld mailing lists, we had a long discussion
there.
I think CODI has something similar, but can't find the naming right now.