/** 配置插件 */ public void configPlugin(Plugins me) { logger.info("配置插件开始.."); DruidPlugin dp = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password")); WallFilter wf = new WallFilter(); wf.setDbType("mysql"); dp.addFilter(wf); me.add(dp); // 配置Ecache插件 me.add(new EhCachePlugin()); // 配置ActiveRecord插件 ActiveRecordPlugin arp = new ActiveRecordPlugin(dp); me.add(arp); arp.setDevMode(true); arp.setShowSql(true); // 此项目并没有用到jfinal2.2的javabean与model的合体,感兴趣的可以参照jfinal官网的demo arp.addMapping("blog", Blog.class); // 映射blog 表到 Blog模型 arp.addMapping("user", User.class); // 用户 arp.addMapping("qquser", Qquser.class); // qq用户 arp.addMapping("blogcategory", Blogcategory.class); // 博客分类 arp.addMapping("userlogininfo", Userlogininfo.class); // 用户登陆信息 arp.addMapping("advice", Advice.class); // 建议 arp.addMapping("role", Role.class); // 角色 arp.addMapping("userrole", Userrole.class); // 用户角色中间表 arp.addMapping("picrecommend", Picrecommend.class); // 首页图片推荐--推荐尺寸为630*350 arp.addMapping("beauty", Beauty.class); // 美图 arp.addMapping("gonggao", Gonggao.class); // 公告 arp.addMapping("iplog", Iplog.class); // ip和URL日志 arp.addMapping("video", Video.class); // 视频模块 arp.addMapping("resourceslog", Resourceslog.class); // 系统资源监控日志 arp.addMapping("link", Link.class); // 友情链接 logger.info("配置插件结束.."); }
/** 配置插件 */ @Override public void configPlugin(Plugins me) { /** 配置Druid数据库连接池插件* */ DruidPlugin dp = new DruidPlugin( ReadPropertity.getProperty("jdbcUrl"), ReadPropertity.getProperty("user"), ReadPropertity.getProperty("password")); dp.addFilter(new StatFilter()); dp.setMaxActive(150); WallFilter wall = new WallFilter(); wall.setDbType(ReadPropertity.getProperty("dbType")); dp.addFilter(wall); me.add(dp); /** 配置ActiveRecord插件* */ ActiveRecordPlugin arp = new ActiveRecordPlugin(dp); me.add(arp); /** 加载EhCache插件* */ me.add(new EhCachePlugin()); arp.addMapping("admin", Admin.class); arp.addMapping("category", Category.class); arp.addMapping("article", Article.class); arp.addMapping("links", Links.class); arp.addMapping("website", Website.class); arp.addMapping("tags", Tags.class); arp.addMapping("gbook", Gbook.class); }
/** * DruidPlugin * * @param prop : property * @return */ private DruidEncryptPlugin getDruidPlugin(String ds) { this.loadPropertyFile(); String url = this.getProperty(String.format("db.%s.url", ds)); url = String.format(URL_TEMPLATE, ds, url); if (!url.endsWith("?characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull")) { url += "?characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull"; } DruidEncryptPlugin dp = new DruidEncryptPlugin( url, this.getProperty(String.format(USER_TEMPLATE, ds)), this.getProperty(String.format(PASSWORD_TEMPLATE, ds))); dp.setInitialSize(this.getPropertyToInt(String.format(INITSIZE_TEMPLATE, ds))); dp.setMaxActive(this.getPropertyToInt(String.format(MAXSIZE_TEMPLATE, ds))); dp.addFilter(new StatFilter()); WallFilter wall = new WallFilter(); wall.setDbType(ds); dp.addFilter(wall); if (!this.geRuned) { dp.start(); BaseModelGenerator baseGe = new BaseModelGenerator(this.getBaseModelPackage(), this.getBaseModelOutDir()); ModelGeneratorExt modelGe = new ModelGeneratorExt( this.getModelPackage(), this.getBaseModelPackage(), this.getModelOutDir()); Generator ge = new Generator(dp.getDataSource(), baseGe, modelGe); ge.setGenerateDataDictionary(this.getGeDictionary()); ge.generate(); } return dp; }