监听器代码如下:
package com.bocean.timer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.bocean.service.eqpt.ICareNovaEqptService;
import com.bocean.socket.BosEqptServer;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.bocean.service.mcenter.IRandCardService;
import java.io.IOException;
/**
*@User only29
*@Date 2014-11-24
*@Time 上午10:35:48
*
*/
public class TaskJobListener implements ServletContextListener {
private static WebApplicationContext context;
private ICareNovaEqptService service;
@Override
public void contextInitialized(ServletContextEvent event) {
event.getServletContext().log("TaskJobListener启动成功!");
event.getServletContext().log("定时器已启动");
//获取spring上下文环境
context = WebApplicationContextUtils.getWebApplication