package com.mybatissist.config;

/**
 * 针对mybatissist的全局配置项
 * @author gris.wang
 * @since 2017/11/1
 */
public class Config {

    private Config(){

    }

    /**
     * 是否打印sql语句
     */
    private boolean printSql;

    /**
     * 是否对各个SQLProvider生成的sql语句进行缓存
     */
    private boolean cacheSql;

    /**
     * 是否对SqlSession进行缓存
     */
    private boolean cacheSqlSession;

    /**
     * 单例
     */
    private static Config config;

    static{
        if(config==null){
            config = new Config();
        }
    }


    //======================================


    /**
     * 获取实例
     * @return
     */
    public static Config instance(){
        return config;
    }

    public Config printSql(boolean printSql){
        config.printSql = printSql;
        return config;
    }

    public boolean printSql(){
        return config.printSql;
    }

    public Config cacheSql(boolean cacheSql){
        config.cacheSql = cacheSql;
        return config;
    }

    public boolean cacheSql(){
        return config.cacheSql;
    }

    public Config cacheSqlSession(boolean cacheSqlSession){
        config.cacheSqlSession = cacheSqlSession;
        return config;
    }

    public boolean cacheSqlSession(){
        return config.cacheSqlSession;
    }


}

@@ -26,16 +26,172 @@
 onfig;%0A%0A
+import com.mybatissist.sqlsession.SqlSessionContext;%0Aimport org.apache.ibatis.session.SqlSession;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 /**%0A * %E9%92%88
@@ -393,10 +393,14 @@
  %E6%98%AF%E5%90%A6%E5%AF%B9
-%E5%90%84%E4%B8%AA
+Select
 SQLP
@@ -449,24 +449,30 @@
 olean cacheS
+electS
 ql;%0A%0A    /**
@@ -1058,16 +1058,22 @@
 g cacheS
+electS
 ql(boole
@@ -1081,16 +1081,22 @@
 n cacheS
+electS
 ql)%7B%0A   
@@ -1113,16 +1113,22 @@
 g.cacheS
+electS
 ql = cac
@@ -1126,24 +1126,30 @@
 Sql = cacheS
+electS
 ql;%0A        
@@ -1195,16 +1195,22 @@
 n cacheS
+electS
 ql()%7B%0A  
@@ -1235,16 +1235,22 @@
 g.cacheS
+electS
 ql;%0A    
@@ -1476,11 +1476,743 @@
 %0A    %7D%0A%0A
+    @Override%0A    public String toString() %7B%0A        return %22%5B%22+super.toString()+%22%5D:%7BprintSql:%22+config.printSql+%22,cacheSelectSql:%22+config.cacheSelectSql+%22,cacheSqlSession:%22+config.cacheSqlSession+%22%7D%22;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        int loopTimes = 200;%0A%0A        class Runner implements Runnable%7B%0A%0A            private Logger logger = LoggerFactory.getLogger(Runner.class);%0A%0A            @Override%0A            public void run() %7B%0A                Config result = Config.instance();%0A                logger.info(%22result=%7B%7D,currentThread=%7B%7D%22,result,Thread.currentThread().getName());%0A            %7D%0A        %7D%0A%0A        for(int i=0;i%3CloopTimes;i++)%7B%0A            new Thread(new Runner()).start();%0A        %7D%0A%0A    %7D%0A
 %0A%7D%0A

add toString