aboutsummaryrefslogtreecommitdiff
path: root/juick-crosspost/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-18 13:48:45 +0700
committerGravatar Vitaly Takmazov2016-11-18 10:07:20 +0300
commit7128df991d737d23ee77f89bfe79ec4b79a362df (patch)
treee02cdb213fb52f2215919f38d0b3244d50a3e94b /juick-crosspost/src/main/java/com/juick
parent5af964e05a79e64f02ebcfb3e1b19f109e32deaf (diff)
one way for inititialization and finalization: using constructor's initialization or method init() and AutoCloseable inteface and method close()
Diffstat (limited to 'juick-crosspost/src/main/java/com/juick')
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java11
1 files changed, 5 insertions, 6 deletions
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();