aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/XMPPConnection.java')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index 6bec6efa..b75ca998 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -4,13 +4,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.juick.User;
-import com.juick.server.MessagesQueries;
-import com.juick.server.SubscriptionsQueries;
+import com.juick.service.MessagesService;
+import com.juick.service.SubscriptionService;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;
import org.springframework.web.socket.TextMessage;
import rocks.xmpp.core.XmppException;
@@ -21,6 +20,7 @@ import rocks.xmpp.core.session.debug.LogbackDebugger;
import rocks.xmpp.core.stanza.model.Message;
import rocks.xmpp.extensions.component.accept.ExternalComponent;
+import javax.inject.Inject;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
@@ -31,7 +31,6 @@ import java.util.stream.Collectors;
public class XMPPConnection implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class);
- private final JdbcTemplate jdbc;
private final WebsocketComponent wsHandler;
private final String xmppPassword;
private final ObjectMapper ms;
@@ -40,15 +39,18 @@ public class XMPPConnection implements AutoCloseable {
private XmppSession xmpp;
+ @Inject
+ MessagesService messagesService;
+ @Inject
+ SubscriptionService subscriptionService;
+
public XMPPConnection(
- final Environment env, final WebsocketComponent wsHandler, final JdbcTemplate jdbc) {
+ final Environment env, final WebsocketComponent wsHandler) {
Assert.notNull(env);
Assert.notNull(wsHandler);
- Assert.notNull(jdbc);
this.wsHandler = wsHandler;
- this.jdbc = jdbc;
xmppPassword = env.getProperty("xmpp_password");
xmppPort = NumberUtils.toInt(env.getProperty("xmpp_port"), 5347);
@@ -76,7 +78,7 @@ public class XMPPConnection implements AutoCloseable {
onJuickMessagePost(jmsg);
} else {
// to get quote
- com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid());
+ com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
onJuickMessageReply(reply);
}
}
@@ -115,7 +117,7 @@ public class XMPPConnection implements AutoCloseable {
private void onJuickMessagePost(final com.juick.Message jmsg) throws JsonProcessingException {
String json = ms.writeValueAsString(jmsg);
- List<Integer> uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUid(), jmsg.getMid())
+ List<Integer> uids = subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())
.stream().map(User::getUid).collect(Collectors.toList());
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c ->
@@ -145,7 +147,7 @@ public class XMPPConnection implements AutoCloseable {
private void onJuickMessageReply(final com.juick.Message jmsg) throws JsonProcessingException {
String json = ms.writeValueAsString(jmsg);
List<Integer> threadUsers =
- SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMid(), jmsg.getUser().getUid())
+ subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid())
.stream().map(User::getUid).collect(Collectors.toList());
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c ->