package kr.co.i4way.config;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.transaction.annotation.EnableTransactionManagement;
//@Configuration
//@MapperScan(value = "kr.co.i4way.mapper.mssql_brd", sqlSessionFactoryRef = "mssqlBrdSqlSessionFactory")
//@EnableTransactionManagement
public class MssqlBrdDataBaseConfig {
	 
//    @Bean(name = "mssqlBrdDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.mssql-brd")
//    public DataSource mssqlDataSource() { 
//        return DataSourceBuilder.create().build();
//    }
//
//    @Bean(name = "mssqlBrdSqlSessionFactory")
//    public SqlSessionFactory mssqlSqlSessionFactory(@Autowired @Qualifier("mssqlBrdDataSource") DataSource mssqlDataSource) throws Exception {
//        SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
//        sqlSessionFactory.setDataSource(mssqlDataSource);
//        sqlSessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver().getResource("classpath:mybatis-config.xml"));
//        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:kr/co/i4way/mybatis/mssql_brd/*.xml"));
//        return sqlSessionFactory.getObject();
//    } 
//
//    @Bean(name = "mssqlBrdSqlSession")
//    public SqlSession sqlSession(SqlSessionFactory sqlSessionFactory) {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
}

