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-xmpp/src/main/java/com/juick/components/XMPPServer.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'juick-xmpp') diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java index cb5172d6..a2f593ee 100644 --- a/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java +++ b/juick-xmpp/src/main/java/com/juick/components/XMPPServer.java @@ -1,7 +1,6 @@ package com.juick.components; import com.juick.components.s2s.*; -import com.juick.util.ThreadHelper; import com.juick.xmpp.JID; import com.juick.xmpp.Stanza; import com.juick.xmpp.StanzaChild; @@ -10,7 +9,6 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.DisposableBean; import org.springframework.core.env.Environment; import org.springframework.jdbc.core.JdbcTemplate; import org.xmlpull.v1.XmlPullParserException; @@ -29,7 +27,7 @@ import java.util.concurrent.ExecutorService; /** * @author ugnich */ -public class XMPPServer implements DisposableBean { +public class XMPPServer implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(XMPPServer.class); public ExecutorService service; @@ -99,7 +97,7 @@ public class XMPPServer implements DisposableBean { } @Override - public void destroy() throws Exception { + public void close() throws Exception { synchronized (getOutConnections()) { for (Iterator i = getOutConnections().iterator(); i.hasNext(); ) { ConnectionOut c = i.next(); @@ -115,9 +113,6 @@ public class XMPPServer implements DisposableBean { i.remove(); } } - - ThreadHelper.shutdownAndAwaitTermination(service); - logger.info("Xmpp server destroyed"); } -- cgit v1.2.3