diff options
author | Vitaly Takmazov | 2018-03-15 14:23:32 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-03-15 14:23:50 +0300 |
commit | 55ec9f370d76a76aa33e290a093995d576e70bdb (patch) | |
tree | 71339f0d94ae1b2935d10efe584ec147e7b57550 /juick-www/src/main/java/com/juick/www/WebApp.java | |
parent | 5d7702b5cf1d3e768b36a04ba802eb164e1916df (diff) |
www: webapp refactoring
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/WebApp.java')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/WebApp.java | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/juick-www/src/main/java/com/juick/www/WebApp.java b/juick-www/src/main/java/com/juick/www/WebApp.java index f254b5fa..94c12528 100644 --- a/juick-www/src/main/java/com/juick/www/WebApp.java +++ b/juick-www/src/main/java/com/juick/www/WebApp.java @@ -18,21 +18,10 @@ package com.juick.www; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.juick.Message; import com.juick.Tag; import com.juick.service.TagService; import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import rocks.xmpp.addr.Jid; -import rocks.xmpp.core.XmppException; -import rocks.xmpp.core.session.Extension; -import rocks.xmpp.core.session.XmppSessionConfiguration; -import rocks.xmpp.core.session.debug.LogbackDebugger; -import rocks.xmpp.extensions.component.accept.ExternalComponent; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -49,25 +38,11 @@ import java.util.stream.Stream; * @author Ugnich Anton */ @Component -public class WebApp implements DisposableBean { - private static Logger logger = LoggerFactory.getLogger(WebApp.class); - - private ExternalComponent xmpp; - +public class WebApp { @Inject private TagService tagService; @Inject private ObjectMapper jsonMapper; - @Value("${xmpp_host:localhost}") - private String xmppHost; - @Value("${xmpp_password:secret}") - private String xmppPassword; - @Value("${www_xmpp_jid:www.juick.local}") - private String xmppJid; - @Value("${xmpp_port:5347}") - private int xmppPort; - @Value("${xmpp_disabled:false}") - private boolean isXmppDisabled; private String scriptsUrl; private String styleUrl; @@ -80,39 +55,6 @@ public class WebApp implements DisposableBean { new TypeReference<HashMap<String, String>>() {}); scriptsUrl = manifest.get("scripts.js"); styleUrl = manifest.get("style.css"); - if (!isXmppDisabled) { - setupXmppComponent(Jid.of(xmppJid), - xmppPassword, xmppPort); - } - } - - @Override - public void destroy() { - try { - if (xmpp != null) - xmpp.close(); - logger.error("ExternalComponent on WWW destroyed"); - } catch (Exception e) { - logger.error("exception on destroy", e); - } - } - - public void setupXmppComponent(final Jid componentJid, final String password, final int port) { - XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() - .extensions(Extension.of(Message.class)) - .debugger(LogbackDebugger.class) - .build(); - xmpp = ExternalComponent.create(componentJid.toString(), password, configuration, xmppHost, port); - xmpp.addConnectionListener(e -> logger.error(e.toString(), e.getCause())); - try { - xmpp.connect(); - } catch (XmppException e) { - logger.error("xmpp extension", e); - } - } - - public ExternalComponent getXmpp() { - return xmpp; } public List<Tag> parseTags(String tagsStr) { |