I have a abstract super class:
public abstract class A<T extends Other> extends B {...}
Another class defined with @ViewScoped
and @Named
is extending A:
public class C extends A<OtherSub> implements Serializable {...}
So far this is no problem.
Now I would like to add observer methods in the super class A
to generically handle CDI events, e.g.:
public void entityCreated(@Observes(notifyObserver = Reception.IF_EXISTS) @Created EntityChangedEvent event) {...}
But deploying this wildfly throws an exception during deployment:
WELD-000404: Conditional observer method cannot be declared by a @Dependent scoped bean: [BackedAnnotatedMethod] public A.entityCreated(@Observes @Created EntityChangedEvent)
I know that I can create the observer without the notifyObserver
condition, but this has the effect, that other beans will be created and notified upon the CDI event, which I would like to prevent.
Is there any way to use the notifyObserver
condition in the generic super class? Or do I need to use it without that condition respectively implement it in the concrete subclass?