Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
_Toc118795405
_Toc118795405
2.10 JSM 起動クラス

JSM が開始すると、内部の起動クラスが実行されます。このクラスは、すべてのJSMサービス・クラスをロードしてXML変換を実行し、できるだけ多くのApache Xalanクラスをロードします。

ユーザー定義の起動クラスは、manager.propertiesファイルの「startup.class」プロパティで指定できます。

startup.class=com.acme.MyStartup
 

ユーザー定義の起動クラスの場合、実行可能インターフェースを実装する必要があります。JSMはこのロードされたクラスを実行可能オブジェクトにキャストして、実行メソッドを実行します。これは、メイン・メソッドで行われるため、専用の追加スレッドは作成されません。

内部の起動クラスとユーザー定義の起動クラスは、JSMが開始してクライアントとコンソールの接続を受け入れる前に実行されます。

例 1

package com.acme ;
 
public final class

...

 MyStartup implements Runnable
{

...

   public void run ()

...

   {

...

        try

...

        {
 

...

            /*   独自のコードはここに記載   */
 

...

        }

...

        catch ( Throwable t )

...

        {

...

             t.printStackTrace () ;

...

        }

...

   }
}

...

例 2

package com.acme ;
 
public final class

...

 MyStartup implements Runnable
{

...

    private int m_sleepTime = 0 ;
 

...

    public MyStartup ()

...

    {

...

        /*
            JSMManager はゼロ引数コンストラクタを使用
        */

        int 

...

seconds = 60 * 20 ; //

...

20分ごと
        Thread thread = new Thread ( new MyStartup ( seconds ) ) ;

...

        thread.start () ;

...

    }
 

...

    public MyStartup ( int seconds )

...

    {

...

        /*
            スリープ時間を指定
        */

        if 

...

( seconds <= 0 )

...

        {

...

            seconds = 0 ;

...

        }

...

        m_sleepTime = seconds * 1000 ;

...

    }
    public 

...

void run ()

...

    {
        if 

...

( m_sleepTime == 0 )

...

        {

...

            /*
               

...

JSMManager呼び出し
            */

...

            System.out.println ( "JSM warmup call" ) ;
 

...

            try

...

            {

...

                warmup () ;

...

            }

...

            catch ( Throwable t )

...

            {

...

                t.printStackTrace () ;

...

            }
            return 

...

;

...

        }
 

...

        /*
            スリープ時間を指定した MyStartup 呼び出し
        */

 

...

        while ( true )

...

        {

...

            try

...

            {

...

                Thread.sleep ( m_sleepTime ) ;
 

...

                System.out.println ( "MyStartup repeat warmup call" ) ;
 

...

                warmup () ;

...

            }

...

            catch ( Throwable t )

...

            {

...

                t.printStackTrace () ;

...

            }

...

        }

...

    }
 

...

    private final void warmup () throws Exception

...

    {

...

        System.out.println ( "MyStartup warmup" ) ;
 

...

        /*   独自のコードはここに記載   */
 

...

    }
}

...