aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications
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-notifications
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-notifications')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java11
1 files changed, 5 insertions, 6 deletions
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();