Example usage for org.apache.ibatis.datasource DataSourceFactory getDataSource

List of usage examples for org.apache.ibatis.datasource DataSourceFactory getDataSource

Introduction

In this page you can find the example usage for org.apache.ibatis.datasource DataSourceFactory getDataSource.

Prototype

DataSource getDataSource();

Source Link

Usage

From source file:cc.oit.dao.impl.mybatis.session.XMLConfigBuilder.java

License:Apache License

private void environmentsElement(XNode context) throws Exception {
    if (context != null) {
        if (environment == null) {
            environment = context.getStringAttribute("default");
        }/*w ww. jav  a2s  .c o  m*/
        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());
            }
        }
    }
}