Package com.zone.weixin4j.dispatcher
Class WeixinMessageDispatcher
- java.lang.Object
-
- com.zone.weixin4j.dispatcher.WeixinMessageDispatcher
-
@Component @DependsOn("weiXin4jContextAware") public class WeixinMessageDispatcher extends Object
微信消息分发器- Since:
- JDK 1.6
- Author:
- jinyu(foxinmy@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description WeixinMessageDispatcher()
WeixinMessageDispatcher(WeixinMessageMatcher messageMatcher)
-
Method Summary
-
-
-
Constructor Detail
-
WeixinMessageDispatcher
public WeixinMessageDispatcher()
-
WeixinMessageDispatcher
public WeixinMessageDispatcher(WeixinMessageMatcher messageMatcher)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
doDispatch
public WeixinResponse doDispatch(WeixinRequest request) throws WeixinException, HttpResponseException, MessageInterceptorException
对消息进行一系列的处理,包括 拦截、匹配、分发等动作- Parameters:
request
- 微信请求- Throws:
WeixinException
HttpResponseException
MessageInterceptorException
-
defineMessageKey
protected WeixinMessageKey defineMessageKey(WeixinMessageTransfer messageTransfer, WeixinRequest request)
声明messagekey- Parameters:
messageTransfer
- 基础消息request
- 请求信息- Returns:
-
noHandlerFound
protected WeixinResponse noHandlerFound(WeixinRequest request, WeixinMessage message) throws HttpResponseException
未匹配到handler时触发- Parameters:
request
- 微信请求message
- 微信消息- Throws:
HttpResponseException
-
getHandlerExecutor
protected MessageHandlerExecutor getHandlerExecutor(WeixinRequest request, WeixinMessageKey messageKey, WeixinMessage message, Set<String> nodeNames) throws WeixinException
MessageHandlerExecutor- Parameters:
request
- 微信请求messageKey
- 消息的keymessage
- 微信消息nodeNames
- 节点名称集合- Returns:
- MessageHandlerExecutor
- Throws:
WeixinException
- See Also:
MessageHandlerExecutor
-
getMessageHandlers
public WeixinMessageHandler[] getMessageHandlers() throws WeixinException
获取所有的handler- Returns:
- handler集合
- Throws:
WeixinException
- See Also:
WeixinMessageHandler
-
getMessageInterceptors
public WeixinMessageInterceptor[] getMessageInterceptors() throws WeixinException
获取所有的interceptor- Returns:
- interceptor集合
- Throws:
WeixinException
-
messageRead
protected <M extends WeixinMessage> M messageRead(String message, Class<M> clazz) throws WeixinException
jaxb读取微信消息- Parameters:
message
- xml消息clazz
- 消息类型- Returns:
- 消息对象
- Throws:
WeixinException
-
getUnmarshaller
protected javax.xml.bind.Unmarshaller getUnmarshaller(Class<? extends WeixinMessage> clazz) throws WeixinException
xml消息转换器- Parameters:
clazz
- 消息类型- Returns:
- 消息转换器
- Throws:
WeixinException
-
setMessageHandlerList
public void setMessageHandlerList(List<WeixinMessageHandler> messageHandlerList)
-
setMessageInterceptorList
public void setMessageInterceptorList(List<WeixinMessageInterceptor> messageInterceptorList)
-
registMessageClass
public void registMessageClass(WeixinMessageKey messageKey, Class<? extends WeixinMessage> messageClass)
-
getMessageMatcher
public WeixinMessageMatcher getMessageMatcher()
-
openAlwaysResponse
public void openAlwaysResponse()
打开总是响应开关,如未匹配到MessageHandler时回复空白消息
-
-