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.java14
1 files changed, 6 insertions, 8 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 24041eeb..ea02db76 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -3,7 +3,6 @@ package com.juick.ws;
import com.juick.User;
import com.juick.json.MessageSerializer;
import com.juick.server.SubscriptionsQueries;
-import com.juick.ws.components.JuickComponent;
import com.juick.xmpp.JID;
import com.juick.xmpp.Message;
import com.juick.xmpp.Stream;
@@ -20,6 +19,7 @@ import javax.inject.Inject;
import java.io.IOException;
import java.net.Socket;
import java.util.List;
+import java.util.concurrent.ExecutorService;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -29,17 +29,19 @@ import java.util.stream.Collectors;
* @author ugnich
*/
@Component
-public class XMPPConnection implements JuickComponent, Stream.StreamListener, Message.MessageListener {
+public class XMPPConnection implements Stream.StreamListener, Message.MessageListener {
private static final Logger logger = Logger.getLogger(XMPPConnection.class.getName());
@Inject
JdbcTemplate sql;
+ ExecutorService service;
Stream xmpp;
String xmppPassword;
MessageSerializer ms;
WebsocketComponent wsHandler;
@Inject
- public XMPPConnection(Environment env) {
+ public XMPPConnection(Environment env, ExecutorService service) {
+ this.service = service;
xmppPassword = env.getProperty("xmpp_password");
ms = new MessageSerializer();
try {
@@ -48,16 +50,12 @@ public class XMPPConnection implements JuickComponent, Stream.StreamListener, Me
xmpp.addChildParser(new JuickMessage());
xmpp.addListener((Stream.StreamListener) this);
xmpp.addListener((Message.MessageListener) this);
+ service.submit(() -> xmpp.startParsing());
} catch (IOException e) {
logger.log(Level.SEVERE, "XMPPConnection error", e);
}
}
- @Async
- @Override
- public void init() {
- xmpp.startParsing();
- }
@Override
public void onStreamReady() {