diff options
author | Alexander Alexeev | 2016-11-14 17:51:22 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-15 09:49:26 +0300 |
commit | 73a2b1d4796ea18ef476f4ca30e2028c828d0ac1 (patch) | |
tree | d331d133dec356f9103af9358ded98c997820f15 /juick-xmpp/src/main | |
parent | f1f61379cab08ecff28e125cba3aa68b78fd66d7 (diff) |
xmpp_disabled option for XMPPServer
Diffstat (limited to 'juick-xmpp/src/main')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/XMPPServer.java | 40 |
1 files changed, 22 insertions, 18 deletions
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); |