/** 标签开始 */ public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); UserInfoVo userInfo = WebUtils.getSessionContainer(request).getUserInfo(); String contextPath = request.getContextPath(); request.setAttribute("webContext", contextPath); Dto dto = new BaseDto(); PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); dto.put("title", WebUtils.getParamValue("SYS_TITLE", request)); dto.put("contextPath", contextPath); String titleIcon = WebUtils.getParamValue("TITLE_ICON", request); dto.put("titleIcon", G4Utils.isEmpty(titleIcon) ? "G4Studio.ico" : titleIcon); Dto themeDto = new BaseDto(); Dto resultDto = new BaseDto(); if (G4Utils.isNotEmpty(userInfo)) { themeDto.put("userid", userInfo.getUserid()); resultDto = armTagSupportService.getEauserSubInfo(themeDto); } String theme = null; if (G4Utils.isNotEmpty(resultDto)) theme = resultDto.getAsString("theme"); String defaultTheme = WebUtils.getParamValue("SYS_DEFAULT_THEME", request); theme = G4Utils.isEmpty(theme) ? defaultTheme : theme; dto.put("theme", theme); String layout = null; if (G4Utils.isNotEmpty(resultDto)) layout = resultDto.getAsString("layout"); String defaultLayout = WebUtils.getParamValue("APP_LAYOUT", request); layout = G4Utils.isEmpty(layout) ? defaultLayout : layout; dto.put("layout", layout); String background = null; if (G4Utils.isNotEmpty(resultDto)) background = resultDto.getAsString("background"); String defaultBackfround = WebUtils.getParamValue("DESKTOP_BACKGROUND", request); background = G4Utils.isEmpty(background) ? defaultBackfround : background; dto.put("background", background); PropertiesHelper p = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); dto.put("extMode", p.getValue("extMode", TagConstant.Ext_Mode_Run)); dto.put("runMode", p.getValue("runMode", TagConstant.RUN_MODE_NORMAL)); dto.put("ajaxErrCode", G4Constants.Ajax_Timeout); String micolor = pHelper.getValue("micolor", "blue"); dto.put("username", WebUtils.getSessionContainer(request).getUserInfo().getUsername()); dto.put("account", WebUtils.getSessionContainer(request).getUserInfo().getAccount()); Dto qDto = new BaseDto(); qDto.put("deptid", WebUtils.getSessionContainer(request).getUserInfo().getDeptid()); dto.put("deptname", armTagSupportService.getDepartmentInfo(qDto).getAsString("deptname")); dto.put("userInfo", userInfo); List menuList = getMenuList(); dto.put("menuList", menuList); dto.put("paramList", WebUtils.getParamList(request)); TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(TemplateType.VELOCITY); DefaultTemplate template = new FileTemplate(); template.setTemplateResource(TagHelper.getTemplatePath(getClass().getName())); StringWriter writer = engine.mergeTemplate(template, dto); try { pageContext.getOut().write(writer.toString()); } catch (IOException e) { log.error(G4Constants.Exception_Head + e.getMessage()); e.printStackTrace(); } return super.SKIP_BODY; }
/** * 初始化ApplicationContext对象 * * @throws Exception */ private static void initApplicationContext() throws Exception { PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); String forceLoad = pHelper.getValue("forceLoad", SystemConstants.FORCELOAD_N); try { if (forceLoad.equalsIgnoreCase(SystemConstants.FORCELOAD_N)) { log.info("系统正在初始化服务容器..."); } applicationContext = new ClassPathXmlApplicationContext(new String[] {"config\\global.config.xml"}); if (forceLoad.equalsIgnoreCase(SystemConstants.FORCELOAD_N)) { log.info("容器初始化成功啦,您的托管Bean已经被实例化。"); } } catch (Exception e) { log.error("服务容器初始化失败."); log.error(G4Constants.Exception_Head + "初始化服务容器发生错误,请仔细检查您的配置文件喔!\n" + e.getMessage()); e.printStackTrace(); System.exit(0); throw e; } }
/** 标签开始 */ public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); UserInfoVo userInfo = WebUtils.getSessionContainer(request).getUserInfo(); String contextPath = request.getContextPath(); request.setAttribute("webContext", contextPath); Dto dto = new BaseDto(); PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); String micolor = pHelper.getValue("micolor", "blue"); dto.put("micolor", micolor); String urlSecurity = pHelper.getValue("urlSecurity", "1"); dto.put("urlSecurity", urlSecurity); dto.put("urlSecurity2", urlSecurity2); dto.put("userInfo", userInfo); dto.put("ajaxErrCode", G4Constants.Ajax_Timeout); dto.put("requestURL", request.getRequestURL()); dto.put("contextPath", contextPath); dto.put("doctypeEnable", doctypeEnable); dto.put("extDisabled", G4Utils.isEmpty(extDisabled) ? "false" : extDisabled); dto.put("title", G4Utils.isEmpty(title) ? "G4Studio" : title); dto.put("jqueryEnabled", G4Utils.isEmpty(jqueryEnabled) ? "false" : jqueryEnabled); dto.put("showLoading", G4Utils.isEmpty(showLoading) ? "true" : showLoading); dto.put("uxEnabled", uxEnabled); dto.put("exportExceptionWindow", exportExceptionWindow); dto.put("fcfEnabled", fcfEnabled); dto.put("exportParams", exportParams); dto.put("exportUserinfo", exportUserinfo); dto.put("isSubPage", isSubPage); dto.put("pageLoadMsg", WebUtils.getParamValue("PAGE_LOAD_MSG", request)); String titleIcon = WebUtils.getParamValue("TITLE_ICON", request); dto.put("titleIcon", G4Utils.isEmpty(titleIcon) ? "G4Studio.ico" : titleIcon); if (exportParams.equals("true")) { dto.put("paramList", WebUtils.getParamList(request)); } // String agent = request.getHeader("user-agent"); // dto.put("firefox", agent.indexOf("Firefox") == -1 ? "false" : "true"); PropertiesHelper p = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); dto.put("extMode", p.getValue("extMode", TagConstant.Ext_Mode_Run)); dto.put("runMode", p.getValue("runMode", TagConstant.RUN_MODE_NORMAL)); Dto themeDto = new BaseDto(); Dto resultDto = new BaseDto(); if (G4Utils.isNotEmpty(userInfo)) { themeDto.put("userid", userInfo.getUserid()); resultDto = armTagSupportService.getEauserSubInfo(themeDto); } String theme = null; if (G4Utils.isNotEmpty(resultDto)) theme = resultDto.getAsString("theme"); String defaultTheme = WebUtils.getParamValue("SYS_DEFAULT_THEME", request); theme = G4Utils.isEmpty(theme) ? defaultTheme : theme; dto.put("theme", theme); TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(TemplateType.VELOCITY); DefaultTemplate template = new FileTemplate(); template.setTemplateResource(TagHelper.getTemplatePath(getClass().getName())); StringWriter writer = engine.mergeTemplate(template, dto); try { pageContext.getOut().write(writer.toString()); } catch (IOException e) { log.error(G4Constants.Exception_Head + e.getMessage()); e.printStackTrace(); } return super.EVAL_BODY_INCLUDE; }
/** 应用平台启动 */ private void systemStartup(ServletContext servletContext) { PropertiesHelper pHelper = PropertiesFactory.getPropertiesHelper(PropertiesFile.G4); String forceLoad = pHelper.getValue("forceLoad", SystemConstants.FORCELOAD_N); long start = System.currentTimeMillis(); if (forceLoad.equalsIgnoreCase(SystemConstants.FORCELOAD_N)) { log.info("*******************************************************"); log.info("G4系统集成与应用开发平台[G4Studio]开始启动..."); log.info("*******************************************************"); } try { wac = SpringBeanLoader.getApplicationContext(); } catch (Exception e) { success = false; e.printStackTrace(); } if (success) { MonitorService monitorService = (MonitorService) SpringBeanLoader.getSpringBean("monitorService"); monitorService.deleteHttpSession(new BaseDto()); try { initDbType(); } catch (SQLException e) { e.printStackTrace(); } } if (success) { log.info("系统开始启动字典装载程序..."); log.info("开始加载字典..."); Reader g4Reader = (Reader) SpringBeanLoader.getSpringBean("g4Reader"); List codeList = null; try { codeList = g4Reader.queryForList("Resource.getCodeViewList"); log.info("字典加载成功!"); } catch (Exception e) { success = false; log.error("字典加载失败!"); e.printStackTrace(); } servletContext.setAttribute("EACODELIST", codeList); } if (success) { log.info("系统开始启动全局参数表装载程序..."); log.info("开始加载全局参数表..."); List paramList = null; try { Reader g4Reader = (Reader) SpringBeanLoader.getSpringBean("g4Reader"); paramList = g4Reader.queryForList("Resource.getParamList"); log.info("全局参数表加载成功!"); } catch (Exception e) { success = false; log.error("全局参数表加载失败!"); e.printStackTrace(); } servletContext.setAttribute("EAPARAMLIST", paramList); } long timeSec = (System.currentTimeMillis() - start) / 1000; log.info("********************************************"); if (success) { log.info("G4系统集成与应用开发平台[G4Studio]启动成功[" + G4Utils.getCurrentTime() + "]"); log.info("启动总耗时: " + timeSec / 60 + "分 " + timeSec % 60 + "秒 "); } else { log.error("G4系统集成与应用开发平台[G4Studio]启动失败[" + G4Utils.getCurrentTime() + "]"); log.error("启动总耗时: " + timeSec / 60 + "分" + timeSec % 60 + "秒"); } log.info("********************************************"); }