From 75d80dc433348435c1f8e11fafb0d1deda1ca793 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 26 Jan 2016 20:09:27 +0300 Subject: import s2s component --- src/main/java/com/juick/xmpp/s2s/Shutdown.java | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/com/juick/xmpp/s2s/Shutdown.java (limited to 'src/main/java/com/juick/xmpp/s2s/Shutdown.java') diff --git a/src/main/java/com/juick/xmpp/s2s/Shutdown.java b/src/main/java/com/juick/xmpp/s2s/Shutdown.java new file mode 100644 index 00000000..fb3543f8 --- /dev/null +++ b/src/main/java/com/juick/xmpp/s2s/Shutdown.java @@ -0,0 +1,45 @@ +package com.juick.xmpp.s2s; + +import java.sql.SQLException; +import java.util.Iterator; + +/** + * + * @author ugnich + */ +public class Shutdown extends Thread { + + @Override + public void run() { + System.out.println("SHUTTING DOWN"); + + synchronized (XMPPComponent.outConnections) { + for (Iterator i = XMPPComponent.outConnections.iterator(); i.hasNext();) { + ConnectionOut c = i.next(); + c.closeConnection(); + i.remove(); + } + } + + synchronized (XMPPComponent.inConnections) { + for (Iterator i = XMPPComponent.inConnections.iterator(); i.hasNext();) { + ConnectionIn c = i.next(); + c.closeConnection(); + i.remove(); + } + } + + XMPPComponent.connRouter.closeConnection(); + + synchronized (XMPPComponent.sqlSync) { + if (XMPPComponent.sql != null) { + try { + XMPPComponent.sql.close(); + XMPPComponent.sql = null; + } catch (SQLException e) { + System.err.println("SQL ERROR: " + e); + } + } + } + } +} -- cgit v1.2.3