-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
黄志磊
committed
Jan 5, 2016
1 parent
6a62d4d
commit 994e92a
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
mpush-tools/src/main/java/com/shinemo/mpush/tools/redis/listener/ListenerDispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.shinemo.mpush.tools.redis.listener; | ||
|
||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import com.google.common.collect.Maps; | ||
|
||
public class ListenerDispatcher implements MessageListener { | ||
|
||
private Map<String, MessageListener> holder = Maps.newTreeMap(); | ||
|
||
public static ListenerDispatcher instance = new ListenerDispatcher(); | ||
|
||
private ListenerDispatcher() { | ||
} | ||
|
||
@Override | ||
public void onMessage(String channel, String message) { | ||
Iterator<Map.Entry<String, MessageListener>> it = holder.entrySet().iterator(); | ||
while (it.hasNext()) { | ||
Map.Entry<String, MessageListener> entry = it.next(); | ||
entry.getValue().onMessage(channel, message); | ||
} | ||
} | ||
|
||
|
||
} |
8 changes: 8 additions & 0 deletions
8
mpush-tools/src/main/java/com/shinemo/mpush/tools/redis/listener/MessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.shinemo.mpush.tools.redis.listener; | ||
|
||
|
||
public interface MessageListener { | ||
|
||
void onMessage(String channel, String message); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters