不要使用 WebLogic ApplicationLifecycleListener 介面

使用此規則來偵測用於實作 WebLogic weblogic.application.ApplicationLifecycleListener 介面的類別。這些類別無法在 WebSphere Application Server 上執行。建議的移轉替代方案是使用 javax.servlet.ServletContextListener 介面。

ApplicationLifecycleListener 實作的複雜性而定,可以使用 ServletContextListener contextInitialized 方法實作來封裝 ApplicationLifecycleListener preStartApplicationLifecycleListener postStart 方法。同樣地,可以使用 ServletContextListener contextDestroyed 方法實作來封裝 ApplicationLifecycleListener preStopApplicationLifecycleListener postStop 方法。

實作 ServletContextListener 之後,將必須更新 WAR 模組的 web.xml。具體地說,必須新增 ServletContextListener 介面的實作,作為 listener-class 元素。請參考下列範例,以取得更新 web.xml 的適當語法。

<web-app id="WebApp_ID">
...
<listener>
<listener-class>com.acme.demo.impl.MyServletContextListenerImpl</listener-class>
</listener>
...
</web-app>

如需相關資訊,請參閱 javax.servlet.ServletContextListener 介面 Java 說明文件。