java 通过配置监听器(Listener)设置项目启动给LED推送数据
来源:互联网 发布:dijkstra算法 matlab 编辑:程序博客网 时间:2024/06/05 11:14
web.xml 配置
<listener>
<listener-class>com.***.***.listenvision.LedContextListener</listener-class>
</listener>
LedContextListener 文件
package com.***.***.listenvision;
import com.***.***.model.AttDetail;
import com.***.***.service.AttDetailService;
import com.***.***.service.FaceService;
import com.***.pay.common.exceptions.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
public class LedContextListener implements ServletContextListener{
private static Logger logger = LoggerFactory.getLogger(LedContextListener.class);
public static ResourceBundle faceSdk = PropertyResourceBundle.getBundle("face-sdk");
public static String LEDSwitch = faceSdk.getString("led.switch");
private AttDetailService attDetailService;
private FaceService faceService;
/**
* 项目启动给LED推送数据
* @param sce
*/
@Override
public void contextInitialized(ServletContextEvent sce) {
logger.info("获取******信息推送给LED(项目启动给LED推送数据)");
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
attDetailService = webApplicationContext.getBean(AttDetailService.class);
faceService = webApplicationContext.getBean(FaceService.class);
try {
if("ON".equals(LEDSwitch)){
//获取最近一名***的信息
AttDetail attDetail = attDetailService.getLatestEmp();
if(!StringUtils.isEmpty(attDetail)){
faceService.attendanceFace(attDetail.getEmpUuid(),attDetail.getInOut().toString());
}
}
} catch (ValidationException ve) {
logger.error(ve.getMessage(), ve);
throw ve;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
}
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
<listener>
<listener-class>com.***.***.listenvision.LedContextListener</listener-class>
</listener>
LedContextListener 文件
package com.***.***.listenvision;
import com.***.***.model.AttDetail;
import com.***.***.service.AttDetailService;
import com.***.***.service.FaceService;
import com.***.pay.common.exceptions.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
public class LedContextListener implements ServletContextListener{
private static Logger logger = LoggerFactory.getLogger(LedContextListener.class);
public static ResourceBundle faceSdk = PropertyResourceBundle.getBundle("face-sdk");
public static String LEDSwitch = faceSdk.getString("led.switch");
private AttDetailService attDetailService;
private FaceService faceService;
/**
* 项目启动给LED推送数据
* @param sce
*/
@Override
public void contextInitialized(ServletContextEvent sce) {
logger.info("获取******信息推送给LED(项目启动给LED推送数据)");
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
attDetailService = webApplicationContext.getBean(AttDetailService.class);
faceService = webApplicationContext.getBean(FaceService.class);
try {
if("ON".equals(LEDSwitch)){
//获取最近一名***的信息
AttDetail attDetail = attDetailService.getLatestEmp();
if(!StringUtils.isEmpty(attDetail)){
faceService.attendanceFace(attDetail.getEmpUuid(),attDetail.getInOut().toString());
}
}
} catch (ValidationException ve) {
logger.error(ve.getMessage(), ve);
throw ve;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
}
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
阅读全文
0 0
- java 通过配置监听器(Listener)设置项目启动给LED推送数据
- Java web项目listener Filter servlet启动顺序和配置
- Java web项目listener Filter servlet启动顺序和配置
- Java web项目listener Filter servlet启动顺序和配置
- Java web项目listener Filter servlet启动顺序和配置
- 配置listener监听器
- 配置listener监听器
- 配置listener监听器
- 配置listener监听器
- Spring配置Listener监听器
- 监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计
- 监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计
- 监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计
- 监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计
- 监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计
- java web listener 监听器
- Java监听器Listener
- Java监听器Listener使用说明
- java中与mySQL数据库中longtext类型对应的类型
- Centos7重启docker报错:Error starting daemon: error ini...tatus 2
- linux 常用命令
- NYOJ完全背包
- linux tail 命令详解及与head命令和sed命令
- java 通过配置监听器(Listener)设置项目启动给LED推送数据
- Java消息队列--ActiveMq 实战
- C++操作SQLITE获得查询结果集的几种方法总结
- java 解析苹果安装包,解析出标识,图标等信息
- Java创建pojo对象对web或者移动端页面显示需求的承载(折扣计算)
- Oracle分区索引--本地索引和全局索引比较
- 开发过程遇到的IE兼容性问题以及解决方案
- 【Python爬虫系列】使用requests爬取图片
- 使用反射机制调用属性和私有成员与代理模式的介绍