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.java13
1 files changed, 5 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 4a80eec5..430a7d59 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -8,6 +8,7 @@ import com.juick.xmpp.Message;
import com.juick.xmpp.Stream;
import com.juick.xmpp.StreamComponent;
import com.juick.xmpp.extensions.JuickMessage;
+import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@@ -26,24 +27,20 @@ import java.util.stream.Collectors;
* @author ugnich
*/
@Component
-public class XMPPConnection implements Runnable, Stream.StreamListener, Message.MessageListener {
+public class XMPPConnection implements InitializingBean, Stream.StreamListener, Message.MessageListener {
private static final Logger logger = Logger.getLogger(XMPPConnection.class.getName());
@Inject
JdbcTemplate sql;
+ @Inject
+ Environment env;
Stream xmpp;
String xmppPassword;
MessageSerializer ms;
WebsocketComponent wsHandler;
- @Inject
- public XMPPConnection(Environment env, WebsocketComponent wsHandler) {
- this.wsHandler = wsHandler;
+ public void afterPropertiesSet() {
xmppPassword = env.getProperty("xmpp_password");
ms = new MessageSerializer();
- }
-
- @Override
- public void run() {
try {
Socket socket = new Socket("localhost", 5347);
xmpp = new StreamComponent(new JID("", "ws.juick.com", ""), socket.getInputStream(), socket.getOutputStream(), xmppPassword);