当前位置: 首页>>代码示例>>Java>>正文


Java DataSourceFactory类代码示例

本文整理汇总了Java中org.apache.ibatis.datasource.DataSourceFactory的典型用法代码示例。如果您正苦于以下问题:Java DataSourceFactory类的具体用法?Java DataSourceFactory怎么用?Java DataSourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSourceFactory类属于org.apache.ibatis.datasource包,在下文中一共展示了DataSourceFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: environmentsElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private void environmentsElement(XNode context) throws Exception {
    if (context != null) {
        if (environment == null) {
            environment = context.getStringAttribute("default");
        }
        for (XNode child : context.getChildren()) {
            String id = child.getStringAttribute("id");
            if (isSpecifiedEnvironment(id)) {
                TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
                DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
                DataSource dataSource = dsFactory.getDataSource();
                Environment.Builder environmentBuilder = new Environment.Builder(id)
                        .transactionFactory(txFactory)
                        .dataSource(dataSource);
                configuration.setEnvironment(environmentBuilder.build());
            }
        }
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:20,代码来源:MybatisXMLConfigBuilder.java

示例2: environmentsElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private void environmentsElement(XNode context) throws Exception {
  if (context != null) {
    if (environment == null) {
      environment = context.getStringAttribute("default");
    }
    for (XNode child : context.getChildren()) {
      String id = child.getStringAttribute("id");
      if (isSpecifiedEnvironment(id)) {
        TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
        DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
        DataSource dataSource = dsFactory.getDataSource();
        Environment.Builder environmentBuilder = new Environment.Builder(id)
            .transactionFactory(txFactory)
            .dataSource(dataSource);
        configuration.setEnvironment(environmentBuilder.build());
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:20,代码来源:XMLConfigBuilder.java

示例3: environmentsElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private void environmentsElement(XNode context) throws Exception {
	if (context != null) {
		if (environment == null) {
			environment = context.getStringAttribute("default");
		}
		for (XNode child : context.getChildren()) {
			String id = child.getStringAttribute("id");
			if (isSpecifiedEnvironment(id)) {
				TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
				DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
				DataSource dataSource = dsFactory.getDataSource();
				Environment.Builder environmentBuilder = new Environment.Builder(id)
						.transactionFactory(txFactory)
						.dataSource(dataSource);
				configuration.setEnvironment(environmentBuilder.build());
			}
		}
	}
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:20,代码来源:XMLConfigBuilder.java

示例4: environmentsElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private void environmentsElement(XNode context) throws Exception {
  if (context != null) {
    if (environment == null) {
      environment = context.getStringAttribute("default");
    }
    for (XNode child : context.getChildren()) {
      String id = child.getStringAttribute("id");
//循环比较id是否就是指定的environment
      if (isSpecifiedEnvironment(id)) {
        //7.1事务管理器
        TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
        //7.2数据源
        DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
        DataSource dataSource = dsFactory.getDataSource();
        Environment.Builder environmentBuilder = new Environment.Builder(id)
            .transactionFactory(txFactory)
            .dataSource(dataSource);
        configuration.setEnvironment(environmentBuilder.build());
      }
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:23,代码来源:XMLConfigBuilder.java

示例5: environmentsElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
/**
 * 解析environments节点,并将结果设置到Configuration对象中   
 * 注意:创建envronment时,如果SqlSessionFactoryBuilder指定了特定的环境(即数据源);  则返回指定环境(数据源)的Environment对象,否则返回默认的Environment对象; 
 * 这种方式实现了MyBatis可以连接多数据源
 * Builder模式应用2: 数据库连接环境Environment对象的创建
 * @param context
 * @throws Exception
 */
private void environmentsElement(XNode context) throws Exception {
  if (context != null) {
    if (environment == null) {
      environment = context.getStringAttribute("default");
    }
    for (XNode child : context.getChildren()) {
      String id = child.getStringAttribute("id");
      if (isSpecifiedEnvironment(id)) { //是和默认的环境相同时,解析之  
        //1.创建事务工厂 TransactionFactory  
        TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
        DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
        //2.创建数据源DataSource  
        DataSource dataSource = dsFactory.getDataSource();
        //使用了Environment内置的构造器Builder,传递id、 事务工厂和数据源 
        //3. 构造Environment对象 
        Environment.Builder environmentBuilder = new Environment.Builder(id)
            .transactionFactory(txFactory)
            .dataSource(dataSource);
        //4. 将创建的Envronment对象设置到configuration 对象中 
        configuration.setEnvironment(environmentBuilder.build());
      }
    }
  }
}
 
开发者ID:toulezu,项目名称:play,代码行数:33,代码来源:XMLConfigBuilder.java

示例6: dataSourceElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private DataSourceFactory dataSourceElement(XNode context) throws Exception {
    if (context != null) {
        String type = context.getStringAttribute("type");
        Properties props = context.getChildrenAsProperties();
        DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
        factory.setProperties(props);
        return factory;
    }
    throw new BuilderException("Environment declaration requires a DataSourceFactory.");
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:11,代码来源:MybatisXMLConfigBuilder.java

示例7: buildDataSource

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
/**
 * @param dataSourceClass {@linkplain DataSource}实现类.
 * @param properties
 * @return
 */
public static DataSource buildDataSource(String dataSourceClass, Properties properties)
{
    try
    {
        Class<?> clazz = PackageUtil.newClass(dataSourceClass, null);
        DataSource dataSource = (DataSource) WPTool.newObject(clazz);
        DataSourceFactory factory = new TempFactory(dataSource);
        factory.setProperties(properties);
        return factory.getDataSource();
    } catch (Exception e)
    {
        throw new DBException(e);
    }
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:20,代码来源:MyBatisBridge.java

示例8: dataSourceElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private DataSourceFactory dataSourceElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    Properties props = context.getChildrenAsProperties();
    DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
    factory.setProperties(props);
    return factory;
  }
  throw new BuilderException("Environment declaration requires a DataSourceFactory.");
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:11,代码来源:HierarchicalXMLConfigBuilder.java

示例9: dataSourceElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private DataSourceFactory dataSourceElement(XNode context) throws Exception {
	if (context != null) {
		String type = context.getStringAttribute("type");
		Properties props = context.getChildrenAsProperties();
		DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
		factory.setProperties(props);
		return factory;
	}
	throw new BuilderException("Environment declaration requires a DataSourceFactory.");
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:11,代码来源:XMLConfigBuilder.java

示例10: dataSourceElement

import org.apache.ibatis.datasource.DataSourceFactory; //导入依赖的package包/类
private DataSourceFactory dataSourceElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    Properties props = context.getChildrenAsProperties();
//根据type="POOLED"解析返回适当的DataSourceFactory
    DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
    factory.setProperties(props);
    return factory;
  }
  throw new BuilderException("Environment declaration requires a DataSourceFactory.");
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:12,代码来源:XMLConfigBuilder.java


注:本文中的org.apache.ibatis.datasource.DataSourceFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。