aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/configuration
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-18 13:48:45 +0700
committerGravatar Vitaly Takmazov2016-11-18 10:07:20 +0300
commit7128df991d737d23ee77f89bfe79ec4b79a362df (patch)
treee02cdb213fb52f2215919f38d0b3244d50a3e94b /juick-server/src/main/java/com/juick/configuration
parent5af964e05a79e64f02ebcfb3e1b19f109e32deaf (diff)
one way for inititialization and finalization: using constructor's initialization or method init() and AutoCloseable inteface and method close()
Diffstat (limited to 'juick-server/src/main/java/com/juick/configuration')
-rw-r--r--juick-server/src/main/java/com/juick/configuration/DataConfiguration.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java b/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
index 88fc00b3..9f733184 100644
--- a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
+++ b/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
@@ -1,6 +1,7 @@
package com.juick.configuration;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -13,7 +14,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;
import javax.annotation.Resource;
-import javax.sql.DataSource;
/**
* Created by aalexeev on 11/11/16.
@@ -26,8 +26,10 @@ public class DataConfiguration implements TransactionManagementConfigurer {
@Resource
private Environment env;
+ // NOTE: The close() method will be called automatically with default @Bean settings
+ // But Datasource interface has no close() method
@Bean
- public DataSource dataSource() {
+ public BasicDataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));