com.healthy.common.websocket.holder.JsonMessageHandlerHolder Maven / Gradle / Ivy
package com.healthy.common.websocket.holder;
import com.healthy.common.websocket.handler.JsonMessageHandler;
import com.healthy.common.websocket.message.JsonWebSocketMessage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* JsonMessageHandlerHolder
*
* @author xm.z
*/
public final class JsonMessageHandlerHolder {
private static final Map> MESSAGE_HANDLER_MAP = new ConcurrentHashMap<>();
private JsonMessageHandlerHolder() {
}
public static JsonMessageHandler getHandler(String type) {
return MESSAGE_HANDLER_MAP.get(type);
}
public static void addHandler(JsonMessageHandler jsonMessageHandler) {
MESSAGE_HANDLER_MAP.put(jsonMessageHandler.type(), jsonMessageHandler);
}
}