Hi Christian,

this sounds like a bug. All the resolution caches should be cleared at 
the very end of Weld's bootstrap sequence (after ABD observers are 
called). (see 
https://github.com/weld/core/blob/master/impl/src/main/java/org/jboss/weld/bootstrap/WeldStartup.java#L415)

Jozef

On 03/04/2014 04:36 PM, Christian Sadilek wrote:
> Hi everyone,
>
> CDI extensions can observe the AfterBeanDiscovery event to register observer 
> methods (addObserverMethod). However, when an event is first fired, the 
> observers for that event are resolved and then cached (in TypeSafeResolver). 
> All future calls to addObserverMethod for an already fired event with 
> corresponding qualifiers will have no effect because the observer result is 
> read from cache and not recomputed.
>
> >From an API perspective that's unfortunate because addObserverMethod will 
> >only work until an event (with corresponding qualifiers) is fired and there 
> >is no indication to the caller of that method that it didn't have any effect 
> >when invoked after that.
>
> Possible solutions:
>
> - Provide some public API to clear/recompute that part the observer cache. 
> Maybe that exists? I couldn't find it which is why I am using the private API 
> and Reflection :(. Also let AfterBeanDiscovery.addObserverMethod fail in that 
> case with the advice to reset the cache.
>
> - Recompute the corresponding part of the cache when addObserverMethod is 
> called (seems preferable).
>
> OpenWebBeans doesn't have this issue as their NotificationManager will simply 
> add the new ObserverMethod to a ConcurrentHashMap that is also accessed when 
> an event is fired.
>
> What do you think? Can this already be done or is there another solution?
>
> Cheers,
> Christian
>
>
>
>
>
>
>
> _______________________________________________
> weld-dev mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/weld-dev

_______________________________________________
weld-dev mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-dev

Reply via email to