[move to weld-dev as this has become a spec discussion]
Speaking to Stuart on IRC, he summarised it for me as:
"What I wanted to do was look for an annotation on a class
@Generic(DroolsConfiguration.class), and then for every DroolsConfiguration that gets
installed install a new one of that class with the same qualifiers but by the time I know
about the class, it is to late, and I would need to use AfterBeanDiscovery.addBean. I
think there are more use cases as well, basically anything that wants to add beans based
on what it finds in the deployment and it is much easier to do it with addAnnotatedType
I think this can be easily solved by making the initialisation lifecycle a bit more
1) Fire BeforeBeanDiscovery [*] , firing ProcessAnnotatedType for each type added via
2) Discover all AnnotatedTypes from bean archives, firing ProcessAnnotatedType for each
3) Fire AfterTypeDiscovery <<< Inserted step, firing ProcessAnnotatedType for
each type added via ProcessAnnotatedType
4) Fire ProcessBean for each Bean created
5) Fire AfterBeanDiscovery
[*] Possibly you would want to rename BeforeBeanDiscovery to BeforeTypeDiscovery in an
Is it possible to get this into the MR?
On 13 Apr 2010, at 00:47, Stuart Douglas wrote:
So this is going to be much harder to implement than I thought.
Because I want to look at the types that come through ProcessAnnotatedType I need to
install the generic beans using AfterBeanDiscovery.addBean. This is much harder to use for
this purpose than BeforeBeanDiscovery.addAnnotatedType, and no matter what I do there will
be subtle and not so subtle differences between these beans and 'native' weld bean
(e.g. interceptors and decorators won't work).
Ideally it would also be possible to do AfterBeanDiscovery.addAnnotatedType, however for
the moment the only real solution that I can see is to put this functionality in the XML
module, and require the extension developer to explicitly declare their generic beans in
XML. This way all the information is available in BeforeBeanDiscovery, and I can add the
generic beans using addAnnotatedType.
I think the syntax would be something like this:
Does this sound like a reasonable solution?
From: seam-dev-bounces(a)lists.jboss.org [seam-dev-bounces(a)lists.jboss.org] On Behalf Of
Tihomir Surdilovic [tsurdilo(a)redhat.com]
Sent: Tuesday, 13 April 2010 12:18 AM
Subject: Re: [seam-dev] Extending weld-extensions generic beans
On 4/12/10 9:51 AM, Stuart Douglas wrote:
> After talking with Tihomir over the last few days about the seam-drools module I
think that there is base functionality that is missing that belongs in weld-extensions as
it is similar to the existing generic bean code.
> I will use an example from the drools module to outline the problem:
> The drools module has a DroolsConfiguration object that contains configuration, this
can be installed via XML and there can be multiple DroolsConfigrations per app. for every
DroolsConfiguration several object need to be produced e.g. KnowledgeBase,
StatefullKnowledgeSession and a KnowledgeRuntimeLogger.
> currently we would need to do something like this:
> < d:DroolsConfiguration>
> ...same for StatefullKnowledgeSession, StatelessKnowledgeSession,
> and wire up a producer like that for every object being created from the
DroolsConfiguration. This is not good. The user should be able to just wire up the
configuration and the rest of the beans should be created automatically. I think we should
be able to do something like this:
> class KnowledgeBaseProducer
> public KnowledgeBase producerMethod(@Inject @GenericQualifiers DroolsConfiguration
> //do stuff
and also disposer methods with for example:
void disposerMethod(@Disposes @GenericQualifiers KnowledgeBase kbase)
> @Generic tell the extensions to register a new KnowledgeBaseProducer bean for every
> @GenericQualifiers is replaced with the qualifiers on the DroolsConfiguration object
when the bean is added.
> This means that all an end user has to do is wire up a single DroolsConfiguration
object and everything just works.
> Does this sound like a good idea? Is there anything I have overlooked?
> seam-dev mailing list
seam-dev mailing list
seam-dev mailing list