aboutsummaryrefslogtreecommitdiff
path: root/juick-crosspost/src/main/java/com
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
parent40c1a196d019fbaf3dd8f0d8f6d1bdc8225bb7a0 (diff)
ws: fix injection
Diffstat (limited to 'juick-crosspost/src/main/java/com')
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java4
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostConfiguration.java14
2 files changed, 15 insertions, 3 deletions
diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
index 493fa5e4..55d1370d 100644
--- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
+++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java
@@ -57,7 +57,6 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message
public final static String TWITTERURL = "https://api.twitter.com/1.1/statuses/update.json";
public final static String FBURL = "https://graph.facebook.com/me/feed";
public final static String VKURL = "https://api.vk.com/method/wall.post";
- @Inject
JdbcTemplate jdbc;
Stream xmpp;
String twitter_consumer_key;
@@ -65,8 +64,9 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message
ExecutorService service;
@Inject
- public Crosspost(Environment env, ExecutorService service) {
+ public Crosspost(Environment env, ExecutorService service, JdbcTemplate jdbc) {
this.service = service;
+ this.jdbc = jdbc;
logger.info("component initialized");
try {
twitter_consumer_key = env.getProperty("twitter_consumer_key", "");
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() {