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() --- juick-ws/src/main/java/com/juick/ws/XMPPConnection.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'juick-ws/src/main') diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java index fb510306..30dad3f3 100644 --- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java +++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java @@ -4,12 +4,9 @@ import com.juick.User; import com.juick.json.MessageSerializer; import com.juick.server.MessagesQueries; import com.juick.server.SubscriptionsQueries; -import com.juick.util.ThreadHelper; import org.apache.commons.lang3.math.NumberUtils; 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.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; @@ -23,13 +20,12 @@ import rocks.xmpp.extensions.component.accept.ExternalComponent; import java.io.IOException; import java.util.List; -import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; /** * @author ugnich */ -public class XMPPConnection implements InitializingBean, DisposableBean { +public class XMPPConnection implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class); private final JdbcTemplate jdbc; @@ -56,10 +52,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean { wsJid = env.getProperty("ws_jid", "ws.juick.local"); ms = new MessageSerializer(); - } - @Override - public void afterPropertiesSet() { XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .extensions(Extension.of(com.juick.Message.class)) .build(); @@ -91,7 +84,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean { } @Override - public void destroy() throws Exception { + public void close() throws Exception { if (xmpp != null) xmpp.close(); -- cgit v1.2.3