From 4679da47ffedf2a0f29c324880fa537fe9447f39 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Fri, 18 Nov 2016 03:47:00 +0700 Subject: correct closing babble components implemented --- .../src/main/java/com/juick/components/XMPPFTServer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'juick-xmpp-ft') diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java index 93baba70..d411179c 100644 --- a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java +++ b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java @@ -26,11 +26,13 @@ import java.util.concurrent.ExecutionException; /** * Created by vitalyster on 11.11.2016. */ -public class XMPPFTServer { +public class XMPPFTServer implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(XMPPFTServer.class); + private ExternalComponent component; + public XMPPFTServer(Environment env) { - ExternalComponent component = ExternalComponent.create(env.getProperty("component_name", "files"), + component = ExternalComponent.create(env.getProperty("component_name", "files"), env.getProperty("component_password", "secret"), env.getProperty("component_host", "localhost"), NumberUtils.toInt(env.getProperty("component_port", "5347"), 5347)); String tmpDir = env.getProperty("upload_tmp_dir", "/tmp"); @@ -80,4 +82,12 @@ public class XMPPFTServer { logger.error("ft initialization error", e); } } + + @Override + public void close() throws Exception { + if (component != null) + component.close(); + + logger.info("ExternalComponent on xmpp-ft destroyed"); + } } -- cgit v1.2.3