From f8da0413163ccf941afd91217de2f767422362a4 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 8 Aug 2016 16:56:10 +0300 Subject: juick-www: using xmpp port from config --- juick-www/src/main/java/com/juick/www/Main.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'juick-www') diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 63194fbd..c249995f 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -24,6 +24,7 @@ import com.juick.xmpp.StreamComponent; import net.jodah.failsafe.Execution; import net.jodah.failsafe.RetryPolicy; import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.lang3.math.NumberUtils; import org.springframework.jdbc.core.JdbcTemplate; import org.xmlpull.v1.XmlPullParserException; import ru.sape.Sape; @@ -89,7 +90,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { sql = new JdbcTemplate(dataSource); sqlSearch = new JdbcTemplate(dataSourceSearch); - setupXmppComponent(new JID(conf.getProperty("www_xmpp_jid", "www.juick.local")), conf.getProperty("xmpp_password")); + setupXmppComponent(new JID(conf.getProperty("www_xmpp_jid", "www.juick.local")), + conf.getProperty("xmpp_password"), NumberUtils.toInt(conf.getProperty("xmpp_port", ""), 5347)); twitterAuth = new TwitterAuth(conf.getProperty("twitter_consumer_key"), conf.getProperty("twitter_consumer_secret")); pagesNewMessage = new NewMessage(conf.getProperty("upload_tmp_dir", "/var/www/juick.com/i/tmp/"), @@ -105,7 +107,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } - public void setupXmppComponent(final JID componentJid, final String password) { + public void setupXmppComponent(final JID componentJid, final String password, final int port) { @SuppressWarnings("unchecked") RetryPolicy retryPolicy = new RetryPolicy() .withBackoff(1, 30, TimeUnit.SECONDS) .withJitter(0.1) @@ -114,7 +116,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { executorService.submit(() -> { while (!execution.isComplete()) { try { - Socket socket = new Socket("localhost", 5347); + Socket socket = new Socket("localhost", port); xmpp = new StreamComponent(componentJid, socket.getInputStream(), socket.getOutputStream(), password); xmpp.addListener(Main.this); xmpp.startParsing(); -- cgit v1.2.3