|
@@ -51,6 +51,7 @@ public class ConnectionFactory extends SpringConnectionFactory {
|
|
|
|
|
|
private ConnectionFactory() {
|
|
private ConnectionFactory() {
|
|
try {
|
|
try {
|
|
|
|
+ dataSource = buildDataSource();
|
|
sqlSessionFactory = getSqlSessionFactory();
|
|
sqlSessionFactory = getSqlSessionFactory();
|
|
sqlSessionTemplate = getSqlSessionTemplate();
|
|
sqlSessionTemplate = getSqlSessionTemplate();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -69,12 +70,18 @@ public class ConnectionFactory extends SpringConnectionFactory {
|
|
*/
|
|
*/
|
|
private SqlSessionTemplate sqlSessionTemplate;
|
|
private SqlSessionTemplate sqlSessionTemplate;
|
|
|
|
|
|
|
|
+ private DataSource dataSource;
|
|
|
|
+
|
|
|
|
+ public DataSource getDataSource() {
|
|
|
|
+ return dataSource;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* get the data source
|
|
* get the data source
|
|
*
|
|
*
|
|
* @return druid dataSource
|
|
* @return druid dataSource
|
|
*/
|
|
*/
|
|
- public DruidDataSource getDataSource() {
|
|
|
|
|
|
+ private DataSource buildDataSource() {
|
|
|
|
|
|
DruidDataSource druidDataSource = new DruidDataSource();
|
|
DruidDataSource druidDataSource = new DruidDataSource();
|
|
|
|
|
|
@@ -112,10 +119,9 @@ public class ConnectionFactory extends SpringConnectionFactory {
|
|
* @throws Exception sqlSessionFactory exception
|
|
* @throws Exception sqlSessionFactory exception
|
|
*/
|
|
*/
|
|
private SqlSessionFactory getSqlSessionFactory() throws Exception {
|
|
private SqlSessionFactory getSqlSessionFactory() throws Exception {
|
|
- DataSource dataSource = getDataSource();
|
|
|
|
TransactionFactory transactionFactory = new JdbcTransactionFactory();
|
|
TransactionFactory transactionFactory = new JdbcTransactionFactory();
|
|
|
|
|
|
- Environment environment = new Environment("development", transactionFactory, dataSource);
|
|
|
|
|
|
+ Environment environment = new Environment("development", transactionFactory, getDataSource());
|
|
|
|
|
|
MybatisConfiguration configuration = new MybatisConfiguration();
|
|
MybatisConfiguration configuration = new MybatisConfiguration();
|
|
configuration.setEnvironment(environment);
|
|
configuration.setEnvironment(environment);
|
|
@@ -125,7 +131,7 @@ public class ConnectionFactory extends SpringConnectionFactory {
|
|
|
|
|
|
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
|
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
|
sqlSessionFactoryBean.setConfiguration(configuration);
|
|
sqlSessionFactoryBean.setConfiguration(configuration);
|
|
- sqlSessionFactoryBean.setDataSource(dataSource);
|
|
|
|
|
|
+ sqlSessionFactoryBean.setDataSource(getDataSource());
|
|
|
|
|
|
sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.*.enums");
|
|
sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.*.enums");
|
|
sqlSessionFactory = sqlSessionFactoryBean.getObject();
|
|
sqlSessionFactory = sqlSessionFactoryBean.getObject();
|