Jeecg 容器初始化监听器

 

文件位置:

F:\jeecg-bpm-3.8\jeecg-bpm-3.8-master\jeecg-bpm-3.8\src\main\java\org\jeecgframework\web\system\listener\InitListener.java

 

 1 package org.jeecgframework.web.system.listener;
 2 
 3 import javax.servlet.ServletContextEvent;
 4 
 5 import org.apache.commons.lang.CommonRandomUtil;
 6 import org.apache.commons.lang.StringUtil;
 7 import org.jeecgframework.web.system.service.DynamicDataSourceServiceI;
 8 import org.jeecgframework.web.system.service.MutiLangServiceI;
 9 import org.jeecgframework.web.system.service.SystemService;
10 import org.springframework.web.context.WebApplicationContext;
11 import org.springframework.web.context.support.WebApplicationContextUtils;
12 
13 
14 /**
15  * 系统初始化监听器,在系统启动时运行,进行一些初始化工作
16  * @author laien
17  *
18  */
19 public class InitListener  implements javax.servlet.ServletContextListener {
20     
21     public void contextDestroyed(ServletContextEvent arg0) {
22         
23     }
24 
25     public void contextInitialized(ServletContextEvent event) {
26         WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
27         SystemService systemService = (SystemService) webApplicationContext.getBean("systemService");
28 //        MenuInitService menuInitService = (MenuInitService) webApplicationContext.getBean("menuInitService");
29         MutiLangServiceI mutiLangService = (MutiLangServiceI) webApplicationContext.getBean("mutiLangService");
30         DynamicDataSourceServiceI dynamicDataSourceService = (DynamicDataSourceServiceI) webApplicationContext.getBean("dynamicDataSourceService");
31         
32         /**
33          * 第一部分:对数据字典进行缓存
34          */
35         if(StringUtil.isNotEmpty(systemService)){
36             systemService.initAllTypeGroups();
37             systemService.initAllTSIcons();
38         }
39         
40         
41 //        /**
42 //         * 第二部分:自动加载新增菜单和菜单操作权限
43 //         * 说明:只会添加,不会删除(添加在代码层配置,但是在数据库层未配置的)
44 //         */
45 //        if("true".equals(ResourceUtil.getConfigByName("auto.scan.menu.flag").toLowerCase())){
46 //            menuInitService.initMenu();
47 //        }
48         
49         /**
50          * 第三部分:加载多语言内容
51          */
52         if(StringUtil.isNotEmpty(systemService)){
53             mutiLangService.initAllMutiLang();
54         }
55         
56         /**
57          * 第四部分:加载配置的数据源信息
58          */
59         if(StringUtil.isNotEmpty(systemService)){
60             dynamicDataSourceService.initDynamicDataSource();
61         }
62     }
63     
64     /**
65      * 自动加载新增菜单和菜单操作权限
66      * 说明:只会添加,不会删除(添加在代码层配置,但是在数据库层未配置的)
67      */
68     private static boolean initMenuFlag = CommonRandomUtil.TRUE;    
69 }

 

posted @ 2019-06-06 15:44  DarJeely  阅读(690)  评论(0编辑  收藏  举报