[weld-dev] Generic Beans

Stuart Douglas stuart at baileyroberts.com.au
Fri Jan 22 04:45:09 EST 2010


Sorry, my email client seems to have sone something weird with that last email, it should have read:


I have been looking into Gavin's ideas for generic beans, as specified at http://seamframework.org/Weld/PortableExtensionsPackage, 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 value stored

- 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 initial value. 

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)

Stuart


More information about the weld-dev mailing list