...
内部の起動クラスとユーザー定義の起動クラスは、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 ;
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" ) ;
/* 独自のコードはここに記載 */
}
}
|