Maybe I'm missing something, but with Java 8 we can have default methods inside an Interface and I`m trying to modify an existing one, adding a new default method that Observes an Event and calls the old method signature at this same Interface, just to avoid code changes in legacy Beans (in this case, all @ApplicationScoped). Ex:
public interface A {
public void oldMehtod(Event evt);
default void newMethod(@Observes Event evt) {
this.oldMehtod(Event evt);
}
}
The "newMethod" is never fired by a Bean that implements this Interface. What I`m missing? Thanks in advance!
From CDI specification, you may want to read more about it then just this quotation:
An observer method is a non-abstract method of a managed bean class or session bean class...
Yours is not a method of a managed bean class. You will need to place that method on an actual bean class to have it discovered.
I cannot tell you exactly why you cannot have them on interfaces but I suppose it's some hard limitation. That would be good question to ask on CDI-dev mailing list.