From 7128df991d737d23ee77f89bfe79ec4b79a362df Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Fri, 18 Nov 2016 13:48:45 +0700 Subject: one way for inititialization and finalization: using constructor's initialization or method init() and AutoCloseable inteface and method close() --- .../src/main/java/com/juick/components/Notifications.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'juick-notifications/src') 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 ea428a2d..ebc69bd1 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -38,8 +38,6 @@ 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; import org.springframework.http.HttpMethod; @@ -49,6 +47,7 @@ import rocks.xmpp.core.session.Extension; import rocks.xmpp.core.session.XmppSessionConfiguration; import rocks.xmpp.extensions.component.accept.ExternalComponent; +import javax.annotation.PostConstruct; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -57,7 +56,7 @@ import java.util.List; /** * @author Ugnich Anton */ -public class Notifications implements InitializingBean, DisposableBean { +public class Notifications implements AutoCloseable { private static Logger logger = LoggerFactory.getLogger(Notifications.class); private final RestTemplate rest; @@ -84,8 +83,8 @@ public class Notifications implements InitializingBean, DisposableBean { xmppPushPassword = env.getProperty("push_xmpp_password", ""); } - @Override - public void afterPropertiesSet() { + @PostConstruct + public void init() { XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .extensions(Extension.of(com.juick.Message.class)) .build(); @@ -211,7 +210,7 @@ public class Notifications implements InitializingBean, DisposableBean { } @Override - public void destroy() throws Exception { + public void close() throws Exception { if (xmpp != null) xmpp.close(); -- cgit v1.2.3