From 94f85e2ec113efee03def8ae9539cdaee21cccf9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 28 Mar 2018 11:27:29 +0300 Subject: drop sphinx search and use datasource autoconfiguration --- .../com/juick/configuration/XMPPConfiguration.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java (limited to 'juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java') diff --git a/juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java b/juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java new file mode 100644 index 00000000..91f55759 --- /dev/null +++ b/juick-www/src/main/java/com/juick/configuration/XMPPConfiguration.java @@ -0,0 +1,43 @@ +package com.juick.configuration; + +import com.juick.Message; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +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; + +@Configuration +public class XMPPConfiguration { + private static Logger logger = LoggerFactory.getLogger(XMPPConfiguration.class); + @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; + @Bean + public ExternalComponent xmpp() { + XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() + .extensions(Extension.of(Message.class)) + .debugger(LogbackDebugger.class) + .build(); + ExternalComponent xmpp = ExternalComponent.create(xmppJid, xmppPassword, configuration, xmppHost, xmppPort); + xmpp.addConnectionListener(e -> logger.error(e.toString(), e.getCause())); + if (!isXmppDisabled) try { + xmpp.connect(); + } catch (XmppException e) { + logger.error("xmpp extension", e); + } + return xmpp; + } +} -- cgit v1.2.3