aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/XMPPComponent.java28
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 21efaeab5..d0b231e24 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);