|
@@ -0,0 +1,56 @@
|
|
|
+package com.xt.js.gkaq.web.system;
|
|
|
+
|
|
|
+import java.lang.reflect.Field;
|
|
|
+
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.http.HttpServlet;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.web.context.support.WebApplicationContextUtils;
|
|
|
+
|
|
|
+import com.xt.js.gkaq.frame.service.ParamService;
|
|
|
+import com.xt.js.gkaq.frame.system.FrameParam;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 系统初始化处理
|
|
|
+ *
|
|
|
+ * @author 袁晓冬
|
|
|
+ */
|
|
|
+public class FrameInitServlet extends HttpServlet {
|
|
|
+ protected Logger logger = LoggerFactory.getLogger(FrameInitServlet.class);
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 系统初始化处理
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void init() throws ServletException {
|
|
|
+ super.init();
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ try {
|
|
|
+ initParam();
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("系统初始化异常:" + e.getMessage());
|
|
|
+ }
|
|
|
+ System.err.println("------System init success cost:" + (System.currentTimeMillis() - start) + "-------");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化系统参数
|
|
|
+ */
|
|
|
+ private void initParam() {
|
|
|
+ ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
|
|
|
+ ParamService paramService = context.getBean(ParamService.class);
|
|
|
+ Field paramServiceField;
|
|
|
+ try {
|
|
|
+ paramServiceField = FrameParam.class.getDeclaredField("paramService");
|
|
|
+ paramServiceField.setAccessible(true);
|
|
|
+ paramServiceField.set(FrameParam.class, paramService);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("系统参数初始化失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ FrameParam.reloadFromCodes();
|
|
|
+ }
|
|
|
+}
|