Ok, I have fixed the test and and committed it. I also changed it so you need an @Inject
annotation to inject the configuration annotation. The second case is slightly harder, as
you need to do type safe resolution to determine if the bean being injected is a generic
bean, however as this occurs in the initialization code there is no guarantee that the
bean you are interested in has been installed yet, so you can't just get the bean
manager to do the lookup for you.
From: Pete Muir [pmuir(a)redhat.com]
Sent: Tuesday, 2 March 2010 11:45 PM
To: Stuart Douglas
Subject: Re: [weld-dev] Generic Beans
Sorry for the late reply. Got bogged down. Anyway...
Your idea seems about right. I tried out your code, I can't get the test to pass (I
get an NPE).
Also, the test case classes don't quite match what I expected. I expected it to look
public class GenericDep
@Inject TestAnnotation data;
public String getValue()
public class GenericMain
public String getValue()
I suggest you add this to weld-extensions, we can then work on getting the tests to pass
and the syntax fixed. WDYT?
On 22 Jan 2010, at 09:29, Stuart Douglas wrote:
I have been looking into Gavin's ideas for generic beans, as specified at
, and I have come up with a simple
prototype. The details of the implementation is as follows:
- All AnnotatedTypes marked @Generic are vetoed and their details stored for later use.
- All beans that have a generic producer field have the details of the Generic annotation
- after bean discovery a new bean is registered for every @Generic annotation type and
every instance of the Generic annotation on a producer field. So in the example on the
wiki page six beans would be registed, 3 Topics and 3 sessions, one each for
'default', 'prices' and 'deals'. these beans have a synthetic
qualifier annotation added to them that only the PE knows about. Also at this point any
@InjectGeneric on the annotated type is replaced with @Inject @SyntheticQualifier(value=?)
so that generic beans can inject other generic beans.
- The injectionTarget for beans with a generic producer field is wrapped to set the
The prototype contains a simple test, it contains two generic beans, GenericMain and
GenericDep, both are generic on TestAnnotation. GenericDep is injected into GenericMain
which is then exposed via a producer field in GenericProducer and injected into
InjectedBean. GenericDep injects an instance of TestAnnotation as configuration.
Could someone have a look at this and let me know if this approach is ok? (In order to
build it you may need to get the most recent weld-extensions from svn)
weld-dev mailing list