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/Notifications.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'juick-notifications/src/main/java/com') diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index 21e85c37..ea428a2d 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -38,6 +38,7 @@ import org.apache.http.util.TextUtils; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.env.Environment; @@ -56,7 +57,7 @@ import java.util.List; /** * @author Ugnich Anton */ -public class Notifications implements InitializingBean { +public class Notifications implements InitializingBean, DisposableBean { private static Logger logger = LoggerFactory.getLogger(Notifications.class); private final RestTemplate rest; @@ -209,6 +210,14 @@ public class Notifications implements InitializingBean { } } + @Override + public void destroy() throws Exception { + if (xmpp != null) + xmpp.close(); + + logger.info("ExternalComponent on notifications destroyed"); + } + String getWnsAccessToken() throws IOException, IllegalStateException { if (TextUtils.isEmpty(wns_application_sip)) { throw new IllegalStateException("'wns_application_sip' is not initialized"); -- cgit v1.2.3