diff options
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/XMPPComponent.java')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/XMPPComponent.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index 2b293fd6..13df5fd0 100644 --- a/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java +++ b/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java @@ -3,10 +3,16 @@ package com.juick.xmpp.s2s; import com.juick.xmpp.Stanza; import com.juick.xmpp.StanzaChild; import com.juick.xmpp.extensions.JuickMessage; +import org.xmlpull.v1.XmlPullParserException; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; @@ -100,11 +106,11 @@ public class XMPPComponent implements ServletContextListener { return null; } - public static void sendOut(Stanza s) throws Exception { + public static void sendOut(Stanza s) { sendOut(s.to.Host, s.toString()); } - public static void sendOut(String hostname, String xml) throws Exception { + public static void sendOut(String hostname, String xml) { boolean haveAnyConn = false; ConnectionOut connOut = null; @@ -146,8 +152,13 @@ public class XMPPComponent implements ServletContextListener { } if (!haveAnyConn) { - ConnectionOut connectionOut = new ConnectionOut(hostname); - XMPPComponent.executorService.submit(connectionOut); + ConnectionOut connectionOut = null; + try { + connectionOut = new ConnectionOut(hostname); + XMPPComponent.executorService.submit(connectionOut); + } catch (CertificateException | UnrecoverableKeyException | NoSuchAlgorithmException | XmlPullParserException | KeyStoreException | KeyManagementException | IOException e) { + LOGGER.log(Level.SEVERE, "s2s out error", e); + } } } @@ -170,9 +181,7 @@ public class XMPPComponent implements ServletContextListener { conf.getProperty("mysql_username", "") + "&password=" + conf.getProperty("mysql_password", "")); childParsers.put(JuickMessage.XMLNS, new JuickMessage()); - - connRouter = new ConnectionRouter(componentName); - executorService.submit(connRouter); + executorService.submit(() -> connRouter = new ConnectionRouter(componentName, conf.getProperty("xmpp_password"))); executorService.submit(new ConnectionListener()); executorService.submit(new CleaningUp()); } catch (Exception e) { @@ -201,7 +210,11 @@ public class XMPPComponent implements ServletContextListener { } } - XMPPComponent.connRouter.closeConnection(); + try { + XMPPComponent.connRouter.closeConnection(); + } catch (IOException e) { + LOGGER.log(Level.WARNING, "router warning", e); + } synchronized (XMPPComponent.sqlSync) { if (XMPPComponent.sql != null) { |