I'm trying to disable 2 observer methods of a class which is in a beans archive jar (more specifically, the class LoginListener
of Seam 3 Faces module), and use mines instead.
I have a web project, with a beans archive in it :
app.war
\- WEB-INF
\- lib
\- seam-faces-3.1.0.Final.jar
|- my-beans.jar
In my-beans.jar
I've got that class :
@Alternative
public class MyLoginListener extends LoginListener {
@Override
public void observePostLoginEvent(final PostLoginEvent event) {
}
@Override
public void observePreLoginEvent(final PreLoginEvent event) {
}
}
Then, in my-beans.jar/META-INF/beans.xml
I activate it :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<alternatives>
<class>com.mycompagny.MyLoginListener</class>
</alternatives>
</beans>
And, same content in app.war/WEB-INF/beans.xml
.
Here I don't understand why, but it's still the original LoginListener
observePostLoginEvent(@Observes PostLoginEvent event)
and observePreLoginEvent
which are called... does somebody know why ?
Did you try to annotate your class also with @Specializes (@Alternative @Specializes)? According to Weld Reference this way you can completely "hide" the other bean (with its producers and observers)