[seam-dev] CDI EG requires feedback
Pete Muir
pmuir at redhat.com
Wed Aug 15 09:17:24 EDT 2012
All, the CDI EG requires feedback on an item in the spec which is not clear, and has been implemented differently between implementations, and is not TCK tested. As Seam-dev contains lots of extensions authors, requesting feedback. Please either send direct to me, or post to cdi-dev at lists.jboss.org :-)
Stuart, your feedback on this would be good, as it relates to XML config.
------------------------------------------------------------------------------------------------------------------------------------------------
Multiple Annotated Types
====================
https://issues.jboss.org/browse/CDI-58
This concerns whether there can be greater than one annotated type per class instance in the JVM. Gavin intended there should be, principally to support an XML configuration dialect, which could introduce multiple versions of a class, each with a different qualifier. However, this is not TCK tested, and implementations vary in how they support this.
We discussed that this makes an implementation considerably more complex (as there is no easy way to uniquely identify an annotated type e.g. for serialization), and also is pretty confusing for a user (as you now get multiple ProcessAnnotatedType events for each class, making it hard to know which one you want to change).
We looked at alternative solutions, and concluded that if all use cases can be satisfied by adding a new bean, rather than a new annotated type, we would like to explicitly specify that there is only one annotated type per class instance. In CDI 1.1 it is already much easier to add and manipulate beans from annotated types, so we believe that the correct thing here is take this route.
------------------------------------------------------------------------------------------------------------------------------------------------
Does anyone create multiple AnnotatedTypes per class instance? If so, can you please describe:
a) why you need to do this
b) whether you could reimplement by directly creating beans (given that CDI 1.1 allows you to [1])
c) how much effort it would be to reimplement/how much of your codebase this would affect
Thanks!
Pete
[1]
BeanAttributes ba = beanManager.cerateBeanAttributes(annotatedType);
InjectionTarget it = beanmanager.createInjectionTarget(annotatedType);
Bean b = beanManager.createBean(ba, clazz, it);
or
BeanAttributes ba = beanManager.cerateBeanAttributes(annotatedFieldOrMethod);
Producer p = beanmanager.createProducer(annotatedFieldOrMethod);
Bean b = beanManager.createBean(ba, clazz, p);
The Bean can then be registered using
afterBeanDiscovery.addBean(b);
More information about the seam-dev
mailing list