@Override public void afterJFinalStart() { logger.info("afterJFinalStart开始.."); // 公告 List<Gonggao> listGonggao = Gonggao.me.listAll(); JFinal.me().getServletContext().setAttribute("gonggao", listGonggao); // 全局博客分类 List<Blogcategory> listBlogcategory = Blogcategory.me.listAll(); com.fly.common.Constants.setListBlogcategory(listBlogcategory); JFinal.me().getServletContext().setAttribute("cloudcategory", listBlogcategory); // 友情链接 List<Link> listLink = Link.me.listAll(); JFinal.me().getServletContext().setAttribute("systemListLink", listLink); // 网站域名 JFinal.me().getServletContext().setAttribute("siteUrl", PropKit.get("siteUrl")); // 网站名称 JFinal.me().getServletContext().setAttribute("siteName", PropKit.get("siteName")); // 多少插件短地址,注册时候的端地址,需自己注册,在配置文件中修改,默认写的是test JFinal.me() .getServletContext() .setAttribute("duoshuoShortName", PropKit.get("duoshuoShortName")); // 是否开放注册 JFinal.me() .getServletContext() .setAttribute("systemRegisterOpen", PropKit.get("systemRegisterOpen")); // 是否开放普通用户写博客,传美图,发视频 JFinal.me().getServletContext().setAttribute("systemEditOpen", PropKit.get("systemEditOpen")); TimerResourcesLog.start(); // 定时器(目前主要是每天定时清理资源日志,一天有720条资源日志,每天凌晨2点清理一周前的日志,可自己修改时间) TimerManager tm = new TimerManager(); tm.init(); logger.info("afterJFinalStart结束.."); }
// 获取公共数据 public Map<String, Object> getCommonData() { Map<String, Object> commonData = new HashMap<String, Object>(); ServletContext servletContext = JFinal.me().getServletContext(); commonData.put("base", servletContext.getContextPath()); commonData.put("systemConfig", SystemConfigUtil.getSystemConfig()); return commonData; }
@SuppressWarnings({"rawtypes", "unchecked"}) public ActiveRecordPlugin createRecordPlugin(DruidPlugin druidPlugin) { ActiveRecordPlugin arPlugin = new ActiveRecordPlugin(druidPlugin); List<Class<Model>> modelClassList = ClassScaner.scanSubClass(Model.class); if (modelClassList != null) { String tablePrefix = PropKit.use("db.properties").get("db_tablePrefix"); tablePrefix = (StrKit.isBlank(tablePrefix)) ? "" : (tablePrefix.trim()); for (Class<?> clazz : modelClassList) { Table tb = clazz.getAnnotation(Table.class); if (tb == null) continue; String tname = tablePrefix + tb.tableName(); if (StringUtils.isNotBlank(tb.primaryKey())) { arPlugin.addMapping(tname, tb.primaryKey(), (Class<? extends Model<?>>) clazz); } else { arPlugin.addMapping(tname, (Class<? extends Model<?>>) clazz); } DbDialect.mapping(clazz.getSimpleName().toLowerCase(), tname); } } arPlugin.setShowSql(JFinal.me().getConstants().getDevMode()); return arPlugin; }