From 4679da47ffedf2a0f29c324880fa537fe9447f39 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Fri, 18 Nov 2016 03:47:00 +0700 Subject: correct closing babble components implemented --- .../src/main/java/com/juick/components/Crosspost.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'juick-crosspost/src/main/java') diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java index f14749eb..8b56f86d 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.env.Environment; import org.springframework.util.Assert; @@ -45,7 +46,7 @@ import java.util.UUID; /** * @author Ugnich Anton */ -public class Crosspost implements InitializingBean { +public class Crosspost implements InitializingBean, DisposableBean { final static String TWITTERURL = "https://api.twitter.com/1.1/statuses/update.json"; final static String FBURL = "https://graph.facebook.com/me/feed"; final static String VKURL = "https://api.vk.com/method/wall.post"; @@ -110,6 +111,14 @@ public class Crosspost implements InitializingBean { } } + @Override + public void destroy() throws Exception { + if (xmpp != null) + xmpp.close(); + + logger.info("XmppSession on crosspost destroyed"); + } + public boolean facebookPost(final com.juick.Message jmsg) { String token = crosspostService.getFacebookToken(jmsg.getUser().getUid()).orElse(""); if (token.isEmpty()) { -- cgit v1.2.3