diff options
author | Alexander Alexeev | 2016-11-18 03:47:00 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-18 09:24:54 +0300 |
commit | 4679da47ffedf2a0f29c324880fa537fe9447f39 (patch) | |
tree | a40e86f6033492a977447b9696437cb894d24f9d /juick-xmpp-bot | |
parent | c260c0c4a0a8d84a7ef442eb40d5a63e9d5326dc (diff) |
correct closing babble components implemented
Diffstat (limited to 'juick-xmpp-bot')
-rw-r--r-- | juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java index c95c94e3..bced456b 100644 --- a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java +++ b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java @@ -21,6 +21,7 @@ import rocks.xmpp.extensions.version.SoftwareVersionManager; import rocks.xmpp.extensions.version.model.SoftwareVersion; import javax.inject.Inject; +import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; @@ -28,13 +29,15 @@ import java.net.URL; /** * Created by vt on 12/11/2016. */ -public class XMPPBot { +public class XMPPBot implements AutoCloseable{ private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class); @Inject JdbcTemplate jdbc; + private ExternalComponent component; + public XMPPBot(Environment env) { - ExternalComponent component = ExternalComponent.create(env.getProperty("component_name", "juick.com"), + component = ExternalComponent.create(env.getProperty("component_name", "juick.com"), env.getProperty("component_password", "secret"), env.getProperty("component_host", "localhost"), NumberUtils.toInt(env.getProperty("component_port", "5347"), 5347)); Jid juickJid = Jid.of(env.getProperty("xmppbot_jid", "juick@juick.com/Juick")); @@ -88,4 +91,12 @@ public class XMPPBot { logger.error("bot initialization error", e); } } + + @Override + public void close() throws Exception { + if (component != null) + component.close(); + + logger.info("ExternalComponent on xmpp-bot destroyed"); + } } |