aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-09-24 11:54:21 +0300
committerGravatar Vitaly Takmazov2019-09-24 11:54:21 +0300
commit2f2e9aab6194037259625200091949d8648e3409 (patch)
tree4669e3bf5389bf68581094ab01dee4155a91e24f /src/main/java/com/juick/service
parent289afd5a0b510e4501cf421dd9a05bb53bc424c3 (diff)
Use single event model for all application events
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/component/LikeEvent.java36
-rw-r--r--src/main/java/com/juick/service/component/MessageEvent.java31
-rw-r--r--src/main/java/com/juick/service/component/MessageReadEvent.java30
-rw-r--r--src/main/java/com/juick/service/component/NotificationListener.java14
-rw-r--r--src/main/java/com/juick/service/component/SubscribeEvent.java27
-rw-r--r--src/main/java/com/juick/service/component/SystemEvent.java26
-rw-r--r--src/main/java/com/juick/service/component/TopEvent.java21
7 files changed, 27 insertions, 158 deletions
diff --git a/src/main/java/com/juick/service/component/LikeEvent.java b/src/main/java/com/juick/service/component/LikeEvent.java
deleted file mode 100644
index 0d4df70c..00000000
--- a/src/main/java/com/juick/service/component/LikeEvent.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.juick.service.component;
-
-import com.juick.Message;
-import com.juick.User;
-import org.springframework.context.ApplicationEvent;
-
-import java.util.List;
-
-public class LikeEvent extends ApplicationEvent {
- private User user;
- private Message message;
- private List<User> subscribers;
- /**
- * Create a new ApplicationEvent.
- *
- * @param source the object on which the event initially occurred (never {@code null})
- */
- public LikeEvent(Object source, User user, Message message, List<User> subscribers) {
- super(source);
- this.message = message;
- this.user = user;
- this.subscribers = subscribers;
- }
-
- public User getUser() {
- return user;
- }
-
- public Message getMessage() {
- return message;
- }
-
- public List<User> getSubscribers() {
- return subscribers;
- }
-}
diff --git a/src/main/java/com/juick/service/component/MessageEvent.java b/src/main/java/com/juick/service/component/MessageEvent.java
deleted file mode 100644
index 82911a58..00000000
--- a/src/main/java/com/juick/service/component/MessageEvent.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.juick.service.component;
-
-import com.juick.Message;
-import com.juick.User;
-import org.springframework.context.ApplicationEvent;
-
-import java.util.List;
-
-public class MessageEvent extends ApplicationEvent {
- private Message message;
- private List<User> users;
- /**
- * Create a new ApplicationEvent.
- *
- * @param source the object on which the event initially occurred (never {@code null})
- * @param message app message
- * @param interestedUsers users interested in notification
- */
- public MessageEvent(Object source, Message message, List<User> interestedUsers) {
- super(source);
- this.message = message;
- this.users = interestedUsers;
- }
-
- public Message getMessage() {
- return message;
- }
- public List<User> getUsers() {
- return users;
- }
-}
diff --git a/src/main/java/com/juick/service/component/MessageReadEvent.java b/src/main/java/com/juick/service/component/MessageReadEvent.java
deleted file mode 100644
index b2af4a08..00000000
--- a/src/main/java/com/juick/service/component/MessageReadEvent.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.juick.service.component;
-
-import com.juick.Message;
-import com.juick.User;
-import org.springframework.context.ApplicationEvent;
-
-import javax.annotation.Nonnull;
-
-public class MessageReadEvent extends ApplicationEvent {
- private User user;
- private Message message;
- /**
- * Create a new ApplicationEvent.
- *
- * @param source the object on which the event initially occurred (never {@code null})
- */
- public MessageReadEvent(Object source, @Nonnull User user, Message message) {
- super(source);
- this.user = user;
- this.message = message;
- }
-
- public User getUser() {
- return user;
- }
-
- public Message getMessage() {
- return message;
- }
-}
diff --git a/src/main/java/com/juick/service/component/NotificationListener.java b/src/main/java/com/juick/service/component/NotificationListener.java
index 38d0490a..7ca88de8 100644
--- a/src/main/java/com/juick/service/component/NotificationListener.java
+++ b/src/main/java/com/juick/service/component/NotificationListener.java
@@ -6,20 +6,8 @@ import org.springframework.scheduling.annotation.Async;
public interface NotificationListener {
@Async
@EventListener
- void processMessageEvent(MessageEvent messageEvent);
- @Async
- @EventListener
- void processSubscribeEvent(SubscribeEvent subscribeEvent);
- @Async
- @EventListener
- void processLikeEvent(LikeEvent likeEvent);
+ void processSystemEvent(SystemEvent systemEvent);
@Async
@EventListener
void processPingEvent(PingEvent pingEvent);
- @Async
- @EventListener
- void processMessageReadEvent(MessageReadEvent messageReadEvent);
- @Async
- @EventListener
- void processTopEvent(TopEvent topEvent);
}
diff --git a/src/main/java/com/juick/service/component/SubscribeEvent.java b/src/main/java/com/juick/service/component/SubscribeEvent.java
deleted file mode 100644
index 9b644f2f..00000000
--- a/src/main/java/com/juick/service/component/SubscribeEvent.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.juick.service.component;
-
-import com.juick.User;
-import org.springframework.context.ApplicationEvent;
-
-public class SubscribeEvent extends ApplicationEvent {
- private User user;
- private User toUser;
- /**
- * Create a new ApplicationEvent.
- *
- * @param source the object on which the event initially occurred (never {@code null})
- */
- public SubscribeEvent(Object source, User user, User toUser) {
- super(source);
- this.user = user;
- this.toUser = toUser;
- }
-
- public User getUser() {
- return user;
- }
-
- public User getToUser() {
- return toUser;
- }
-}
diff --git a/src/main/java/com/juick/service/component/SystemEvent.java b/src/main/java/com/juick/service/component/SystemEvent.java
new file mode 100644
index 00000000..11a10860
--- /dev/null
+++ b/src/main/java/com/juick/service/component/SystemEvent.java
@@ -0,0 +1,26 @@
+package com.juick.service.component;
+
+import com.juick.Message;
+import com.juick.User;
+import com.juick.server.api.SystemActivity;
+import org.springframework.context.ApplicationEvent;
+
+import java.util.List;
+
+public class SystemEvent extends ApplicationEvent {
+ private SystemActivity activity;
+ /**
+ * Create a new ApplicationEvent.
+ *
+ * @param source the object on which the event initially occurred (never {@code null})
+ * @param activity system activity
+ */
+ public SystemEvent(Object source, SystemActivity activity) {
+ super(source);
+ this.activity = activity;
+ }
+
+ public SystemActivity getActivity() {
+ return activity;
+ }
+}
diff --git a/src/main/java/com/juick/service/component/TopEvent.java b/src/main/java/com/juick/service/component/TopEvent.java
deleted file mode 100644
index b7e24957..00000000
--- a/src/main/java/com/juick/service/component/TopEvent.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.juick.service.component;
-
-import com.juick.Message;
-import org.springframework.context.ApplicationEvent;
-
-public class TopEvent extends ApplicationEvent {
- private Message message;
- /**
- * Create a new ApplicationEvent.
- *
- * @param source the object on which the event initially occurred (never {@code null})
- */
- public TopEvent(Object source, Message message) {
- super(source);
- this.message = message;
- }
-
- public Message getMessage() {
- return message;
- }
-}