zoukankan      html  css  js  c++  java
  • mybatis3源码阅读之SqlSessionFactoryBuilder

    /**
       构造器,根据配置或者代码生成SqlSessionFactory,采用分布构建的Builder模式 
    /*
    public class SqlSessionFactoryBuilder {
     /**
        传入用于读取字符流的类。
      /*
      public SqlSessionFactory build(Reader reader) {
        return build(reader, null, null);
      }
     /**
        传入用于读取字符流的类和环境配置(不同环境数据库各种连接配置不一样)
      /*
      public SqlSessionFactory build(Reader reader, String environment) {
        return build(reader, environment, null);
      }
      
    /**
        传入用于读取字符流的类和环境配置(不同环境数据库各种连接配置不一样)
      /*
      public SqlSessionFactory build(Reader reader, Properties properties) 
      { return build(reader, null, properties);  
      } 
    
    /**
     传入用于读取字符流的类和配置文件
    /*
    public SqlSessionFactory build(Reader reader, Properties properties) {
    return build(reader, null, properties);
    }
    /* 构造
    SqlSessionFactory 具体实现(传入字符流)
    /*
    public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {
    XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties);
    return build(parser.parse());
    } catch (Exception e) {
    throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
    ErrorContext.instance().reset();
    try {
    reader.close();
    } catch (IOException e) {
    // Intentionally ignore. Prefer previous error.
    }
    }
    }
    /**
    传入字节流
    /*
    public SqlSessionFactory build(InputStream inputStream) {
    return build(inputStream, null, null);
    }
    /** 
      传入字节流和环境配置
    /*
    public SqlSessionFactory build(InputStream inputStream, String environment) {
    return build(inputStream, environment, null);
    }
    /** 
      传入字节流和配置文件
    /*
    public SqlSessionFactory build(InputStream inputStream, Properties properties) {
    return build(inputStream, null, properties);
    }

    /* 构造
    SqlSessionFactory 具体实现(传入字节流)
    /*
    public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {
    XMLConfigBuilder parser = new XMLConfigBuilder(inputStream, environment, properties);
    return build(parser.parse());
    } catch (Exception e) {
    throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
    ErrorContext.instance().reset();
    try {
    inputStream.close();
    } catch (IOException e) {
    // Intentionally ignore. Prefer previous error.
    }
    }
    }
    /**
    核心,根据配置配置生成SqlSessionFactory 以上实现都是读取配置转换成配置对象在调用此方法。
    /* 
    public SqlSessionFactory build(Configuration config) {
    return new DefaultSqlSessionFactory(config);
    }
  • 相关阅读:
    利用Dom4j创建xml文档
    eclipse安装、使用hibernate插件方法
    “万能数据库查询分析器”用户已基本涵盖当前所有DBMS
    在Dom4j中使用Xpath搜索xml的元素节点
    多线程的一些小问题集锦
    Dalvik虚拟机的运行过程分析
    创建线程的两种方式
    通过xpath查找指定的节点
    Oracle TNS 配置
    c++五种内存分配、堆与栈区别
  • 原文地址:https://www.cnblogs.com/zhmt/p/10629258.html
Copyright © 2011-2022 走看看