JSF 注释 @ListenerFor 不适用于 GlassFish 或 Tomcat。没有错误或警告。它只是不调用方法 processEvent()。
@ListenersFor({@ListenerFor(systemEventClass=PostConstructApplicationEvent.class),
public class MySystemEventListener implements SystemEventListener {
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if(event instanceof PostConstructApplicationEvent){
System.out.println("*********************************************");
System.out.println("processEvent Method is Called: PostConstructApplicationEvent");
System.out.println("*********************************************");
}
if(event instanceof PreDestroyApplicationEvent){
System.out.println("*********************************************");
System.out.println("processEvent Method is Called: PreDestroyApplicationEvent");
System.out.println("*********************************************");
}
}
@Override
public boolean isListenerForSource(Object o) {
return (o instanceof Application);
}
}
有什么想法?