diff options
author | 2016-07-06 20:18:49 +0300 | |
---|---|---|
committer | 2016-07-06 20:18:49 +0300 | |
commit | a33e6c3926b41a29a5828677cbad265f7c503d57 (patch) | |
tree | f8f007b10ce283c63a9293d2abc42c993a08b846 /src/main/java/com/juick/xmpp | |
parent | 5005833a6f4437c7ad0d3d36bbd8b2da99a904ee (diff) |
refactor
Diffstat (limited to 'src/main/java/com/juick/xmpp')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/XMPPComponent.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index 21efaeab..d0b231e2 100644 --- a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java +++ b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java @@ -159,9 +159,8 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe } if (!haveAnyConn) { - ConnectionOut connectionOut = null; try { - connectionOut = new ConnectionOut(this, hostname); + ConnectionOut connectionOut = new ConnectionOut(this, hostname); executorService.submit(connectionOut); } catch (CertificateException | UnrecoverableKeyException | NoSuchAlgorithmException | XmlPullParserException | KeyStoreException | KeyManagementException | IOException e) { logger.log(Level.SEVERE, "s2s out error", e); @@ -190,16 +189,22 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe bot = new JuickBot(this, Jid); childParsers.put(JuickMessage.XMLNS, new JuickMessage()); - Socket routerSocket = new Socket("localhost", 5347); - router = new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), conf.getProperty("xmpp_password")); - router.addChildParser(new JuickMessage()); - router.addListener((Stream.StreamListener) this); - router.addListener((Message.MessageListener) this); - router.addListener((Iq.IqListener) this); - executorService.submit(() -> router.startParsing()); + + executorService.submit(() -> { + Socket routerSocket = null; + try { + routerSocket = new Socket("localhost", 5347); + router = new StreamComponent(new JID("s2s"), routerSocket.getInputStream(), routerSocket.getOutputStream(), conf.getProperty("xmpp_password")); + router.addChildParser(new JuickMessage()); + router.addListener((Stream.StreamListener) this); + router.addListener((Message.MessageListener) this); + router.addListener((Iq.IqListener) this); + router.startParsing(); + } catch (IOException e) { + logger.log(Level.SEVERE, "router error", e); + } + }); executorService.submit(() -> { - router.startParsing(); - executorService.submit(new CleaningUp(this)); final ServerSocket listener = new ServerSocket(5269); logger.info("s2s listener ready"); while (true) { @@ -213,6 +218,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe } } }); + executorService.submit(new CleaningUp(this)); } catch (Exception e) { logger.log(Level.SEVERE, "XMPPComponent error", e); |