帮助顶一下,顺便学习一下~
解决方案 »
- 导入Excel表时候报错
- struts2不想用property 参数出来的中文自动编码,这么办?
- 什么是'端口跟踪'?
- 生成excel文件为什么最多只能生成9个excel文件,多了就报错误
- 请帮我看下这个关系该怎么建
- ajax 验证
- 如何把接受的电子邮件的内容,存到数据库text字段中呢?
- (急)(急)(急)(急)(急)(急) 我的jsp页面报错!内存溢出,无法编译!请教个位大虾!!
- HTTP Status 500 - Invalid action class configuration that references an unknown
- 如何在JBuider9和Weblogic7环境下搭一个JSP运行环境
- 高分求cookie问题,可以读取也有JSESSIONID,就是无法写入哭!!!
- 一个字符编码的filter 没有起作用
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.InstanceNotFoundException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import weblogic.management.timer.Timer;/**
* 该类实现了NotificationListener(通知监听)接口
*/public final class PlanTask
implements
ServletContextListener, NotificationListener {// private static final long PERIOD = Timer.ONE_HOUR; //小时
private static final long PERIOD = Timer.ONE_DAY;
private Timer timer;
private int count = 0; private Integer notificationId; public void contextInitialized(ServletContextEvent event) {
System.out.println(">>>正在载入......."); // Instantiating the Timer MBean
timer = new Timer();
//============================================================== java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
"M/dd/yyyy hh:mm:ss a", java.util.Locale.US);
java.util.Date d = null;
try {
d = sdf.parse("08/02/2004 13:30:00 AM");
}
catch (Exception e) { }//===================================================================
timer.addNotificationListener(this, null, "some handback Object"); // Adding the notification to the Timer and assigning the
// ID that the Timer returns to a variable
Date timerTriggerAt = new Date( (new Date()).getTime() + 5000L);
notificationId = timer.addNotification("启动任务/分", "a recurring call",
this, d, PERIOD); timer.start();
System.out.println(">>> 定时器已经启动.");
} public void contextDestroyed(ServletContextEvent event) {
System.out.println(">>> 定时器销毁.");
try {
timer.stop();
timer.removeNotification(notificationId);
System.out.println(">>> 定时器已经停止.");
}
catch (InstanceNotFoundException e) {
e.printStackTrace();
}
} /* callback method */
public void handleNotification(Notification notif, Object handback) {
System.out.println("计划任务开始执行");
try {
CallPlan.execuMethod();
}
catch (Exception e) {
System.out.println(e.toString());
}
System.out.println(">>> " + (new Date()) + " 定时器接到执行通知=" +
notif + ", 退回初始状态=" + handback);
}
}