一、build
public SqlSessionFactory build(InputStream inputStream) {
return build(inputStream, null, null);
}
build作用:建立一个SqlSessionFactory
返回值:inputstream输入流
二、build
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.
}
}
}
build作用:建立一个SqlSessionFactory
返回值:
InputStream inputStream:输入流
String environment:环境
Properties properties:属性
XMLConfigBuilder parser = new XMLConfigBuilder(inputStream, environment, properties);
XMLConfigBuilder:读取.xml文件
parser:解析
return build(parser.parse());
返回配置文件
public SqlSessionFactory build(Configuration config) {
return new DefaultSqlSessionFactory(config);
}
三、XMLConfigBuilder
public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
}
XMLConfigBuilder作用:读取.xml文件
参数:
InputStream inputStream:输入流
String environment:环境
Properties props:属性
XPathParser作用:.xml路径解析
public XPathParser(InputStream inputStream, boolean validation, Properties variables, EntityResolver entityResolver) {
commonConstructor(validation, variables, entityResolver);
this.document = createDocument(new InputSource(inputStream));
}
参数:
InputStream inputStream:输入流
boolean validation:布尔类型
Properties variables:属性
EntityResolver entityResolver:实体处理类
commonConstructor:公共构造函数
private void commonConstructor(boolean validation, Properties variables, EntityResolver entityResolver) {
this.validation = validation;
this.entityResolver = entityResolver;
this.variables = variables;
XPathFactory factory = XPathFactory.newInstance();
this.xpath = factory.newXPath();
}
this.document = createDocument(new InputSource(inputStream));
把输入流传进来的资源创建为一个文档
384

被折叠的 条评论
为什么被折叠?



