aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/component
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
committerGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
commit7aaa3f9a29c280f01c677c918932620be45cdbd7 (patch)
tree39947b2c889afd08f9c73ba54fab91159d2af258 /src/main/java/com/juick/service/component
parent3ea9770d0d43fbe45449ac4531ec4b0a374d98ea (diff)
Merge everything into single Spring Boot application
Diffstat (limited to 'src/main/java/com/juick/service/component')
-rw-r--r--src/main/java/com/juick/service/component/DisconnectedEvent.java14
-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.java25
-rw-r--r--src/main/java/com/juick/service/component/PingEvent.java21
-rw-r--r--src/main/java/com/juick/service/component/SubscribeEvent.java27
-rw-r--r--src/main/java/com/juick/service/component/TopEvent.java21
-rw-r--r--src/main/java/com/juick/service/component/UserUpdatedEvent.java23
9 files changed, 228 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/component/DisconnectedEvent.java b/src/main/java/com/juick/service/component/DisconnectedEvent.java
new file mode 100644
index 00000000..552c3e66
--- /dev/null
+++ b/src/main/java/com/juick/service/component/DisconnectedEvent.java
@@ -0,0 +1,14 @@
+package com.juick.service.component;
+
+import org.springframework.context.ApplicationEvent;
+
+public class DisconnectedEvent extends ApplicationEvent {
+ /**
+ * Create a new ApplicationEvent.
+ *
+ * @param source the object on which the event initially occurred (never {@code null})
+ */
+ public DisconnectedEvent(Object source) {
+ super(source);
+ }
+}
diff --git a/src/main/java/com/juick/service/component/LikeEvent.java b/src/main/java/com/juick/service/component/LikeEvent.java
new file mode 100644
index 00000000..0d4df70c
--- /dev/null
+++ b/src/main/java/com/juick/service/component/LikeEvent.java
@@ -0,0 +1,36 @@
+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
new file mode 100644
index 00000000..82911a58
--- /dev/null
+++ b/src/main/java/com/juick/service/component/MessageEvent.java
@@ -0,0 +1,31 @@
+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
new file mode 100644
index 00000000..b070c8cb
--- /dev/null
+++ b/src/main/java/com/juick/service/component/MessageReadEvent.java
@@ -0,0 +1,30 @@
+package com.juick.service.component;
+
+import com.juick.Message;
+import com.juick.User;
+import org.springframework.context.ApplicationEvent;
+
+import java.util.List;
+
+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, 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
new file mode 100644
index 00000000..38d0490a
--- /dev/null
+++ b/src/main/java/com/juick/service/component/NotificationListener.java
@@ -0,0 +1,25 @@
+package com.juick.service.component;
+
+import org.springframework.context.event.EventListener;
+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);
+ @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/PingEvent.java b/src/main/java/com/juick/service/component/PingEvent.java
new file mode 100644
index 00000000..8e3f3fa7
--- /dev/null
+++ b/src/main/java/com/juick/service/component/PingEvent.java
@@ -0,0 +1,21 @@
+package com.juick.service.component;
+
+import com.juick.User;
+import org.springframework.context.ApplicationEvent;
+
+public class PingEvent extends ApplicationEvent {
+ private User pinger;
+ /**
+ * Create a new ApplicationEvent.
+ *
+ * @param source the object on which the event initially occurred (never {@code null})
+ */
+ public PingEvent(Object source, User pinger) {
+ super(source);
+ this.pinger = pinger;
+ }
+
+ public User getPinger() {
+ return pinger;
+ }
+}
diff --git a/src/main/java/com/juick/service/component/SubscribeEvent.java b/src/main/java/com/juick/service/component/SubscribeEvent.java
new file mode 100644
index 00000000..9b644f2f
--- /dev/null
+++ b/src/main/java/com/juick/service/component/SubscribeEvent.java
@@ -0,0 +1,27 @@
+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/TopEvent.java b/src/main/java/com/juick/service/component/TopEvent.java
new file mode 100644
index 00000000..b7e24957
--- /dev/null
+++ b/src/main/java/com/juick/service/component/TopEvent.java
@@ -0,0 +1,21 @@
+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;
+ }
+}
diff --git a/src/main/java/com/juick/service/component/UserUpdatedEvent.java b/src/main/java/com/juick/service/component/UserUpdatedEvent.java
new file mode 100644
index 00000000..af2f579a
--- /dev/null
+++ b/src/main/java/com/juick/service/component/UserUpdatedEvent.java
@@ -0,0 +1,23 @@
+package com.juick.service.component;
+
+import com.juick.User;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.lang.NonNull;
+
+public class UserUpdatedEvent extends ApplicationEvent {
+ private User user;
+ /**
+ * Generated when user is updated (avatar changed, etc).
+ *
+ * @param source the object on which the event initially occurred (never {@code null})
+ * @param user updated user
+ */
+ public UserUpdatedEvent(@NonNull Object source, User user) {
+ super(source);
+ this.user = user;
+ }
+
+ public User getUser() {
+ return user;
+ }
+}