aboutsummaryrefslogtreecommitdiff
path: root/juick-crosspost/src/main/java/com/juick/components/configuration
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-08 16:36:52 +0300
committerGravatar Vitaly Takmazov2016-11-08 17:45:40 +0300
commit7270411d55c154e42c942caeaf4d4b942d72dea2 (patch)
treec102da1c5265d8eed69c3441ccdbb4c953a983ba /juick-crosspost/src/main/java/com/juick/components/configuration
parent40c1a196d019fbaf3dd8f0d8f6d1bdc8225bb7a0 (diff)
ws: fix injection
Diffstat (limited to 'juick-crosspost/src/main/java/com/juick/components/configuration')
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java
index 7ed9fcee..99555a1b 100644
--- a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java
+++ b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java
@@ -8,6 +8,7 @@ import com.mitchellbosecke.pebble.loader.Loader;
import com.mitchellbosecke.pebble.loader.ServletLoader;
import com.mitchellbosecke.pebble.spring4.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring4.extension.SpringExtension;
+import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -16,6 +17,7 @@ import org.springframework.core.env.Environment;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@@ -38,6 +40,16 @@ public class CrosspostConfiguration extends WebMvcConfigurationSupport {
Environment env;
@Inject
ExecutorService service;
+ @Inject
+ JdbcTemplate jdbc;
+
+ @Bean
+ JdbcTemplate jdbc() {
+ BasicDataSource dataSource = new BasicDataSource();
+ dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));
+ dataSource.setUrl(env.getProperty("datasource_url"));
+ return new JdbcTemplate(dataSource);
+ }
@Inject
private ServletContext servletContext;
@@ -70,7 +82,7 @@ public class CrosspostConfiguration extends WebMvcConfigurationSupport {
}
@Bean
public Crosspost crosspost() {
- return new Crosspost(env, service);
+ return new Crosspost(env, service, jdbc);
}
@Bean
public ExecutorService service() {