aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPBot.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-28 23:33:44 +0300
committerGravatar Vitaly Takmazov2018-03-28 23:33:44 +0300
commit024533a558e4827564041bdf5040e51370eece80 (patch)
tree694a7f765ac31d6170b2422060badbe036cd61c2 /juick-server/src/main/java/com/juick/server/XMPPBot.java
parentf6eb11a23ab645b187c5911ec762a3d6ca58140c (diff)
server: refactor event listeners
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPBot.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPBot.java32
1 files changed, 18 insertions, 14 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPBot.java b/juick-server/src/main/java/com/juick/server/XMPPBot.java
index 5f9f83e6..6805b733 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPBot.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java
@@ -19,14 +19,14 @@ package com.juick.server;
import com.juick.Tag;
import com.juick.User;
+import com.juick.formatters.PlainTextFormatter;
import com.juick.server.component.LikeEvent;
import com.juick.server.component.MessageEvent;
import com.juick.server.component.SubscribeEvent;
-import com.juick.server.util.TagUtils;
-import com.juick.server.xmpp.s2s.StanzaListener;
-import com.juick.formatters.PlainTextFormatter;
import com.juick.server.helpers.TagStats;
+import com.juick.server.util.TagUtils;
import com.juick.server.xmpp.helpers.annotation.UserCommand;
+import com.juick.server.xmpp.s2s.StanzaListener;
import com.juick.service.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -36,11 +36,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.annotation.Scope;
-import org.springframework.context.annotation.ScopedProxyMode;
-import org.springframework.context.event.EventListener;
-import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.stanza.model.*;
@@ -49,6 +44,7 @@ import rocks.xmpp.core.stanza.model.client.ClientPresence;
import rocks.xmpp.core.stanza.model.errors.Condition;
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.inject.Inject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -62,8 +58,7 @@ import java.util.stream.Collectors;
* @author ugnich
*/
@Component
-@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
-public class XMPPBot implements StanzaListener, AutoCloseable {
+public class XMPPBot implements StanzaListener, NotificationListener {
private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class);
@@ -319,8 +314,7 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
return true;
}
- @EventListener
- @Async
+ @Override
public void processMessageEvent(MessageEvent event) {
com.juick.Message msg = event.getMessage();
if (msg.getRid() == 0 && msg.getMid() > 0) {
@@ -346,6 +340,16 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
}
}
+ @Override
+ public void processSubscribeEvent(SubscribeEvent subscribeEvent) {
+
+ }
+
+ @Override
+ public void processLikeEvent(LikeEvent likeEvent) {
+
+ }
+
@UserCommand(pattern = "^ping$", patternFlags = Pattern.CASE_INSENSITIVE,
help = "PING - returns you a PONG")
public String commandPing(User user, Jid from, String[] input) {
@@ -764,8 +768,8 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
});
}
- @Override
- public void close() throws Exception {
+ @PreDestroy
+ public void close() {
broadcastPresence(Presence.Type.UNAVAILABLE);
}
}