aboutsummaryrefslogtreecommitdiff
path: root/juick-crosspost/src/main/java/com/juick/components/configuration
diff options
context:
space:
mode:
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() {