diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/ConnectionListener.java | 41 | ||||
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/XMPPComponent.java | 15 |
2 files changed, 14 insertions, 42 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java b/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java deleted file mode 100644 index 607397a89..000000000 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionListener.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.juick.xmpp.s2s; - -import java.net.ServerSocket; -import java.net.Socket; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author vt - */ -public class ConnectionListener implements Runnable { - - private static final Logger logger = Logger.getLogger(ConnectionListener.class.getName()); - - XMPPComponent xmpp; - - public ConnectionListener(XMPPComponent xmpp) { - this.xmpp = xmpp; - } - - @Override - public void run() { - try { - final ServerSocket listener = new ServerSocket(5269); - logger.info("s2s listener ready"); - while (true) { - try { - Socket socket = listener.accept(); - ConnectionIn client = new ConnectionIn(xmpp, new JuickBot(xmpp), socket); - xmpp.addConnectionIn(client); - xmpp.executorService.submit(client); - } catch (Exception e) { - logger.log(Level.SEVERE, "s2s error", e); - } - } - } catch (Exception e) { - logger.log(Level.SEVERE, "s2s listener exception", e); - } - } -} diff --git a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index 245038d4d..db7b11acc 100644 --- a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java +++ b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java @@ -10,6 +10,8 @@ import org.xmlpull.v1.XmlPullParserException; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -184,8 +186,19 @@ public class XMPPComponent implements ServletContextListener { childParsers.put(JuickMessage.XMLNS, new JuickMessage()); executorService.submit(() -> connRouter = new ConnectionRouter(this, componentName, conf.getProperty("xmpp_password"))); - executorService.submit(new ConnectionListener(this)); executorService.submit(new CleaningUp(this)); + final ServerSocket listener = new ServerSocket(5269); + LOGGER.info("s2s listener ready"); + while (true) { + try { + Socket socket = listener.accept(); + ConnectionIn client = new ConnectionIn(this, new JuickBot(this), socket); + addConnectionIn(client); + executorService.submit(client); + } catch (Exception e) { + LOGGER.log(Level.SEVERE, "s2s error", e); + } + } } catch (Exception e) { LOGGER.log(Level.SEVERE, "XMPPComponent error", e); } |