aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPServer.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPServer.java28
1 files changed, 8 insertions, 20 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPServer.java b/juick-server/src/main/java/com/juick/server/XMPPServer.java
index 9dc7bf0a..4a5d577d 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPServer.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPServer.java
@@ -17,9 +17,9 @@
package com.juick.server;
+import com.juick.server.xmpp.router.StreamError;
import com.juick.server.xmpp.s2s.*;
import com.juick.service.UserService;
-import com.juick.xmpp.extensions.StreamError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -59,7 +59,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author ugnich
*/
@Component
-public class XMPPServer implements ConnectionListener, AutoCloseable {
+public class XMPPServer implements ConnectionListener {
private static final Logger logger = LoggerFactory.getLogger("com.juick.server.xmpp");
private static final int TIMEOUT_MINUTES = 15;
@@ -156,23 +156,6 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
});
}
- @Override
- public void close() throws Exception {
- if (listener != null && !listener.isClosed()) {
- listener.close();
- }
- outConnections.forEach((c, s) -> {
- c.logoff();
- outConnections.remove(c);
- });
- inConnections.forEach(c -> {
- c.closeConnection();
- inConnections.remove(c);
- });
- service.shutdown();
- logger.info("XMPP server destroyed");
- }
-
public void addConnectionIn(ConnectionIn c) {
c.setListener(this);
inConnections.add(c);
@@ -443,7 +426,12 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
});
}
@PreDestroy
- public void preDestroy() {
+ public void preDestroy() throws IOException {
closeFlag.set(true);
+ if (listener != null && !listener.isClosed()) {
+ listener.close();
+ }
+ service.shutdown();
+ logger.info("XMPP server destroyed");
}
}