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.tibero", sqlSessionFactoryRef = "tiberoSqlSessionFactory")
//@EnableTransactionManagement
public class TiberoDataBaseConfig {
	 
//	@Primary
//    @Bean(name = "tiberoDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.tibero")
//    public DataSource tiberoDataSource() {
//        return DataSourceBuilder.create().build();
//    }
//	
//	@Primary
//    @Bean(name = "tiberoSqlSessionFactory")
//    public SqlSessionFactory tiberoSqlSessionFactory(DataSource tiberoDataSource) throws Exception {
//        SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
//        sqlSessionFactory.setDataSource(tiberoDataSource);
//        sqlSessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver().getResource("classpath:mybatis-config.xml"));
//        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:kr/co/i4way/mybatis/tibero/*.xml"));
//        return sqlSessionFactory.getObject();
//    }  
//	    
//	@Primary
//    @Bean(name = "tiberoSqlSession")
//    public SqlSession sqlSession(@Qualifier("tiberoSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
}	
