アプリケーション・サーバーの 1 つ以上のカスタム・サービスを作成できます。 各カスタム・サービスでは、サーバーの始動とシャットダウンの際にロードおよび初期化されるクラスを定義しています。 これらのクラスのそれぞれに、com.ibm.websphere.runtime.CustomService インターフェースを 実装する必要があります。カスタム・サービスを作成後、管理コンソールを使用して、 アプリケーション・サーバーのカスタム・サービスを構成します。
サーバーの始動および停止時に、 カスタム・サービスのロードと初期化が行われます。
public class ServerInit implements com.ibm.websphere.runtime.CustomService { /** * The initialize method is called by the application server runtime when the * server starts. The Properties object that the application server passes * to this method must contain all of the configuration information that this * service needs to initialize properly. * * @param configProperties java.util.Properties */ static final java.lang.String externalConfigURLKey = "com.ibm.websphere.runtime.CustomService.externalConfigURLKey"; static String ConfigFileName=""; public void initialize(java.util.Properties configProperties) throws Exception { if (configProperties.getProperty(externalConfigURLKey) != null) { ConfigFileName = configProperties.getProperty(externalConfigURLKey); } // Implement rest of initialize method }
/** * The shutdown method is called by the application server runtime when the * server begins its shutdown processing. * public void shutdown() throws Exception { // Implement shutdown method }
アプリケーション・サーバーを調べて、 カスタム・サービスの初期化メソッドおよびシャットダウン・メソッドが意図したとおりに実行されたことを確認してください。