From 73a2b1d4796ea18ef476f4ca30e2028c828d0ac1 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Mon, 14 Nov 2016 17:51:22 +0700 Subject: xmpp_disabled option for XMPPServer --- .../main/java/com/juick/components/XMPPServer.java | 40 ++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'juick-xmpp') diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java index e26e0a1e..cb5172d6 100644 --- a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java +++ b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java @@ -6,6 +6,7 @@ import com.juick.xmpp.JID; import com.juick.xmpp.Stanza; import com.juick.xmpp.StanzaChild; import com.juick.xmpp.extensions.JuickMessage; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,29 +66,32 @@ public class XMPPServer implements DisposableBean { brokenSSLhosts = Arrays.asList(env.getProperty("broken_ssl_hosts", "").split(",")); bannedHosts = Arrays.asList(env.getProperty("banned_hosts", "").split(",")); bot = new JuickBot(this, Jid); + boolean disabled = BooleanUtils.toBoolean(env.getProperty("xmpp_disabled", "false")); childParsers.put(JuickMessage.XMLNS, new JuickMessage()); - router = new ConnectionRouter(this, componentName, componentPort, env.getProperty("xmpp_password")); - - service.submit(router); - - service.submit(() -> { - final ServerSocket listener = new ServerSocket(s2sPort); - logger.info("s2s listener ready"); - while (true) { - try { - Socket socket = listener.accept(); - ConnectionIn client = new ConnectionIn(this, bot, socket); - addConnectionIn(client); - service.submit(client); - } catch (Exception e) { - logger.error("s2s error", e); + if (!disabled) { + router = new ConnectionRouter(this, componentName, componentPort, env.getProperty("xmpp_password")); + + service.submit(router); + + service.submit(() -> { + final ServerSocket listener = new ServerSocket(s2sPort); + logger.info("s2s listener ready"); + while (true) { + try { + Socket socket = listener.accept(); + ConnectionIn client = new ConnectionIn(this, bot, socket); + addConnectionIn(client); + service.submit(client); + } catch (Exception e) { + logger.error("s2s error", e); + } } - } - }); + }); - service.submit(new CleaningUp(this)); + service.submit(new CleaningUp(this)); + } } catch (Exception e) { logger.error("XMPPComponent error", e); -- cgit v1.2.3