From aaebdd4913a7e5274018675d12231df8caf227a0 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Mon, 14 Nov 2016 04:20:14 +0700 Subject: crosspost service used --- .../src/main/java/com/juick/components/Crosspost.java | 17 ++++++++--------- .../configuration/CrosspostAppConfiguration.java | 5 +++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'juick-crosspost') 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 905816fd..c82fc542 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -17,7 +17,7 @@ */ package com.juick.components; -import com.juick.server.CrosspostQueries; +import com.juick.service.CrosspostService; import com.juick.util.ThreadHelper; import com.juick.xmpp.JID; import com.juick.xmpp.Message; @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.env.Environment; -import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; import javax.crypto.Mac; @@ -56,7 +55,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea private static Logger logger = LoggerFactory.getLogger(Crosspost.class); - private final JdbcTemplate jdbc; + private final CrosspostService crosspostService; private final ExecutorService service; private Stream xmpp; @@ -66,13 +65,13 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea private final String password; private final int port; - public Crosspost(final Environment env, final ExecutorService service, final JdbcTemplate jdbc) { + public Crosspost(final Environment env, final ExecutorService service, final CrosspostService crosspostService) { Assert.notNull(env); Assert.notNull(service); - Assert.notNull(jdbc); + Assert.notNull(crosspostService); this.service = service; - this.jdbc = jdbc; + this.crosspostService = crosspostService; twitter_consumer_key = env.getProperty("twitter_consumer_key", ""); twitter_consumer_secret = env.getProperty("twitter_consumer_secret", ""); @@ -140,7 +139,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean facebookPost(final com.juick.Message jmsg) { - String token = CrosspostQueries.getFacebookToken(jdbc, jmsg.getUser().getUID()).orElse(""); + String token = crosspostService.getFacebookToken(jmsg.getUser().getUID()).orElse(""); if (token.isEmpty()) { return false; } @@ -182,7 +181,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean vkontaktePost(final com.juick.Message jmsg) { - Pair tokens = CrosspostQueries.getVKTokens(jdbc, jmsg.getUser().getUID()).orElse(Pair.of("", "")); + Pair tokens = crosspostService.getVkTokens(jmsg.getUser().getUID()).orElse(Pair.of("", "")); if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) { return false; } @@ -219,7 +218,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean twitterPost(final com.juick.Message jmsg) { - Pair tokens = CrosspostQueries.getTwitterTokens(jdbc, jmsg.getUser().getUID()).orElse(Pair.of("", "")); + Pair tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUID()).orElse(Pair.of("", "")); if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) { return false; } diff --git a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java index a7787b26..603130b3 100644 --- a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java +++ b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java @@ -2,6 +2,7 @@ package com.juick.components.configuration; import com.juick.components.Crosspost; import com.juick.configuration.DataConfiguration; +import com.juick.service.CrosspostService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -23,11 +24,11 @@ public class CrosspostAppConfiguration { @Inject private Environment env; @Inject - private JdbcTemplate jdbcTemplate; + private CrosspostService crosspostService; @Bean public Crosspost crosspost() { - return new Crosspost(env, service(), jdbcTemplate); + return new Crosspost(env, service(), crosspostService); } @Bean -- cgit v1.2.3