@Override
    public void setContext(Context context) {
        super.setContext(context);

        // 添加插件
        HookAggregator.getInstance().setContext(context);

        // 配置插件使用的模板引擎
        PluginConfiguration cfg = PluginTools.getPluginConfiguration(context, CommentPlugin.class);

        if (cfg == null || cfg.getProperty(CommentPlugin.PRO_TEMPLATE) == null) {
            if (context.getCommentGenerator() instanceof DefaultCommentGenerator) {
                // 使用默认模板引擎
                commentGenerator = new TemplateCommentGenerator("default-comment.ftl", true);
            } else {
                // 用户自定义
                commentGenerator = context.getCommentGenerator();
            }
        } else {
            TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator(cfg.getProperty(CommentPlugin.PRO_TEMPLATE), false);

            // ITFSW 插件使用的注释生成器
            commentGenerator = templateCommentGenerator;

            // 修正系统插件
            try {
                // 先执行一次生成CommentGenerator操作，然后再替换
                context.getCommentGenerator();

                BeanUtils.setProperty(context, "commentGenerator", templateCommentGenerator);
            } catch (Exception e) {
                logger.error("反射异常", e);
            }
        }

        // mybatis版本
        if (StringUtility.stringHasValue(context.getProperty(PRO_MYBATIS_VERSION))) {
            this.mybatisVersion = context.getProperty(PRO_MYBATIS_VERSION);
        }
    }
@Override
    public void setContext(Context context) {
        super.setContext(context);

        
        HookAggregator.getInstance().setContext(context);

        
        PluginConfiguration cfg = PluginTools.getPluginConfiguration(context, CommentPlugin.class);

        if (cfg == null || cfg.getProperty(CommentPlugin.PRO_TEMPLATE) == null) {
            if (context.getCommentGenerator() instanceof DefaultCommentGenerator) {
                
                commentGenerator = new TemplateCommentGenerator("default-comment.ftl", true);
            } else {
                
                commentGenerator = context.getCommentGenerator();
            }
        } else {
            TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator(cfg.getProperty(CommentPlugin.PRO_TEMPLATE), false);

            
            commentGenerator = templateCommentGenerator;

            
            try {
                
                context.getCommentGenerator();

                BeanUtils.setProperty(context, "commentGenerator", templateCommentGenerator);
            } catch (Exception e) {
                logger.error("反射异常", e);
            }
        }

        
        if (StringUtility.stringHasValue(context.getProperty(PRO_MYBATIS_VERSION))) {
            this.mybatisVersion = context.getProperty(PRO_MYBATIS_VERSION);
        }
    }
@ Override public void setContext ( Context context ) { super . setContext ( context ) ; // 添加插件 HookAggregator . getInstance ( ) . setContext ( context ) ; // 配置插件使用的模板引擎 PluginConfiguration cfg = PluginTools . getPluginConfiguration ( context , CommentPlugin . class ) ; if ( cfg == null || cfg . getProperty ( CommentPlugin . PRO_TEMPLATE ) == null ) { if ( context . getCommentGenerator ( ) instanceof DefaultCommentGenerator ) { // 使用默认模板引擎 commentGenerator = new TemplateCommentGenerator ( "default-comment.ftl" , true ) ; } else { // 用户自定义 commentGenerator = context . getCommentGenerator ( ) ; } } else { TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator ( cfg . getProperty ( CommentPlugin . PRO_TEMPLATE ) , false ) ; // ITFSW 插件使用的注释生成器 commentGenerator = templateCommentGenerator ; // 修正系统插件 try { // 先执行一次生成CommentGenerator操作，然后再替换 context . getCommentGenerator ( ) ; BeanUtils . setProperty ( context , "commentGenerator" , templateCommentGenerator ) ; } catch ( Exception e ) { logger . error ( "反射异常", e); } } // mybatis版本 if ( StringUtility . stringHasValue ( context . getProperty ( PRO_MYBATIS_VERSION ) ) ) { this . mybatisVersion = context . getProperty ( PRO_MYBATIS_VERSION ) ; } }
Set the context under which this plugin is running.
@param context the new context
Set the context under which this plugin is running .