我想创建一个带有注释的 Faces 应用程序侦听器我有以下类:
package com.chhibi.listener;
import javax.faces.application.Application;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.PostConstructApplicationEvent;
import javax.faces.event.PreDestroyApplicationEvent;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
public class FacesAppListener implements SystemEventListener {
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PostConstructApplicationEvent) {
// other code here
}
if (event instanceof PreDestroyApplicationEvent) {
//other code here
}
}
@Override
public boolean isListenerForSource(Object source) {
// only for Application
return (source instanceof Application);
}
}
我想用faces-config.xml
注解替换下面的配置,怎么办?
<!-- Application is started -->
<system-event-listener>
<system-event-listener-class>
com.chhibi.listenner.FacesAppListener
</system-event-listener-class>
<system-event-class>
javax.faces.event.PostConstructApplicationEvent
</system-event-class>
</system-event-listener>
<!-- Before Application is shut down -->
<system-event-listener>
<system-event-listener-class>
com.chhibi.listenner.FacesAppListener
</system-event-listener-class>
<system-event-class>
javax.faces.event.PreDestroyApplicationEvent
</system-event-class>
</system-event-listener>