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/Crosspost.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'juick-crosspost/src/main/java/com') 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 8b56f86d..5dc86f27 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -23,8 +23,6 @@ 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; import rocks.xmpp.core.XmppException; @@ -34,6 +32,7 @@ import rocks.xmpp.core.session.XmppSessionConfiguration; import rocks.xmpp.core.stanza.model.Message; import rocks.xmpp.extensions.component.accept.ExternalComponent; +import javax.annotation.PostConstruct; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import javax.net.ssl.HttpsURLConnection; @@ -46,7 +45,7 @@ import java.util.UUID; /** * @author Ugnich Anton */ -public class Crosspost implements InitializingBean, DisposableBean { +public class Crosspost implements AutoCloseable { 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"; @@ -85,8 +84,8 @@ public class Crosspost implements InitializingBean, DisposableBean { return ret; } - @Override - public void afterPropertiesSet() { + @PostConstruct + public void init() { XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .extensions(Extension.of(com.juick.Message.class)) .build(); @@ -112,7 +111,7 @@ public class Crosspost implements InitializingBean, DisposableBean { } @Override - public void destroy() throws Exception { + public void close() throws Exception { if (xmpp != null) xmpp.close(); -- cgit v1.2.3