BeanTaskInfo オブジェクトのパラメーターを設定します。
これらのパラメーターは、どの Session Bean がいつ呼び出されるかを定義します。TaskInfo インターフェースには
タスクの実行を制御するための set() メソッドが各種用意されており、いつタスクを実行し、実行時にどのような処理を行うかなどを
設定できます。
BeanTaskInfo インターフェースでは、setTaskHandler メソッドを使用して、TaskHandler JNDI 名または TaskHandlerHome を
設定する必要があります。
タスク・ハンドラーの設定に WASScheduler MBean API を使用する場合は、
JNDI 名が完全修飾のグローバル JNDI 名である必要があります。
TaskInfo インターフェースでは追加の制御点も指定されています。これについては、API 文書を参照してください。
以下のコード例に示すように、TaskInfo
interface API メソッドを使用してパラメーターを設定します。//create a date object which represents 30 seconds from now
java.util.Date startDate = new java.util.Date(System.currentTimeMillis()+30000);
//find the session bean to be called when the task executes
Object o = new InitialContext().lookup("java:comp/env/ejb/MyTaskHandlerHome");
TaskHandlerHome home = (TaskHandlerHome)javax.rmi.PortableRemoteObject.narrow(o,TaskHandlerHome.class);
//now set the start time and task handler to be called in the task info
taskInfo.setTaskHandler(home);
taskInfo.setStartTime(startDate);
以下の JACL スクリプト例を使用してパラメーターを設定することもできます。
# Setup the task
puts "Setting up the task..."
# Set the startTime if you want the task to run at a specific time, for example:
$bti setStartTime [java::new {java.util.Date long} [java::call System currentTimeMillis]]
# Set the StartTimeInterval so the task runs in 30 seconds from now
$bti setStartTimeInterval 30seconds
# Set JNDI name of the EJB which will get called when the task runs. Since there is no
# application J2EE Context when the task is created by the MBean, this must be a
# global JNDI name.
$bti setTaskHandler $taskHandlerHomeJNDIName
# Do not purge the task when it's complete
$bti setAutoPurge false
# Set the name of the task. This can be any string value.
$bti setName Created_by_MBean
# If the task needs to run with specific authorization you can set the tasks Authentication Alias
# Authentication aliases are created using the Admin Console.
# $bti setAuthenticationAlias {myRealm/myAlias}
puts "Task setup completed."