I have not seen too many advantages in doing something like this (and you can tell me some situations where this can be useful!)
@Named
(as you probably know) makes an accessible bean accessible from JSF pages. Applied at the package level, it will simply assign an EL name to all beans in this package. Although I agree with you that this is certainly not a killer function, I can imagine that quite often everything that is required in a particular package should be available through EL. Of course, another question, if you annotate all the beans individually, would not be better in terms of readability.
would it be wise for the CDI (or Seam Solder) to allow arbitrarily qualifiers that would apply to packages, while maintaining the same semantics of this @Named classifier?
@SomeQualifier
would apply the same qualifier to all beans in the package. Contrary to @Named
, I can hardly imagine that this makes sense - looking back at a couple of CDI projects over the past year, I think I never had a package where all the beans in it required the same qualifier. Some sense makes sense if you remember that qualifiers are designed to decouple components ... (Let's say you have an interface with three implementations - almost certainly they will belong to different packages or even jars)
source share