aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-bot
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp-bot')
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java15
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");
+ }
}