使用精靈來建立 EJB 計時器
您可以使用「建立 EJB 計時器」精靈,來建立「Enterprise JavaBeans (EJB) 計時器」,並將它們新增至專案。
開始之前
程序
結果
package com.ibm.test;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
@Stateless
public class MyTimer {
/**
* Default constructor.
*/
public MyTimer() {
// TODO Auto-generated constructor stub
}
@SuppressWarnings("unused")
@Schedule(second="*/10", minute="*", hour="8-23", dayOfWeek="Mon-Fri",
dayOfMonth="*", month="*", year="*", info="MyTimer", persistent=false)
private void scheduledTimeout(final Timer t) {
System.out.println("@Schedule called at: " + new java.util.Date());
}
}