Package com.foxinmy.weixin4j.dispatcher
Class WeixinMessageDispatcher
- java.lang.Object
-
- com.foxinmy.weixin4j.dispatcher.WeixinMessageDispatcher
-
public class WeixinMessageDispatcher extends Object
微信消息分发器- Since:
- JDK 1.6
- Author:
- jinyu(foxinmy@gmail.com)
- See Also:
WeixinMessageHandler
,WeixinMessageInterceptor
,WeixinMessageMatcher
,MessageHandlerExecutor
,BeanFactory
-
-
Constructor Summary
Constructors Constructor Description WeixinMessageDispatcher()
WeixinMessageDispatcher(WeixinMessageMatcher messageMatcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected WeixinMessageKey
defineMessageKey(WeixinMessageTransfer messageTransfer, WeixinRequest request)
声明messagekeyvoid
doDispatch(io.netty.channel.ChannelHandlerContext context, WeixinRequest request)
对消息进行一系列的处理,包括 拦截、匹配、分发等动作BeanFactory
getBeanFactory()
protected MessageHandlerExecutor
getHandlerExecutor(io.netty.channel.ChannelHandlerContext context, WeixinRequest request, WeixinMessageKey messageKey, WeixinMessage message, Set<String> nodeNames)
MessageHandlerExecutorString[]
getMessageHandlerPackages()
WeixinMessageHandler[]
getMessageHandlers()
获取所有的handlerString[]
getMessageInterceptorPackages()
WeixinMessageInterceptor[]
getMessageInterceptors()
获取所有的interceptorWeixinMessageMatcher
getMessageMatcher()
protected javax.xml.bind.Unmarshaller
getUnmarshaller(Class<? extends WeixinMessage> clazz)
xml消息转换器protected <M extends WeixinMessage>
MmessageRead(String message, Class<M> clazz)
jaxb读取微信消息protected void
noHandlerFound(io.netty.channel.ChannelHandlerContext context, WeixinRequest request, WeixinMessage message)
未匹配到handler时触发void
openAlwaysResponse()
打开总是响应开关,如未匹配到MessageHandler时回复空白消息void
registMessageClass(WeixinMessageKey messageKey, Class<? extends WeixinMessage> messageClass)
void
setBeanFactory(BeanFactory beanFactory)
void
setMessageHandlerList(List<WeixinMessageHandler> messageHandlerList)
void
setMessageHandlerPackages(String... messageHandlerPackages)
void
setMessageInterceptorList(List<WeixinMessageInterceptor> messageInterceptorList)
void
setMessageInterceptorPackages(String... messageInterceptorPackages)
-
-
-
Constructor Detail
-
WeixinMessageDispatcher
public WeixinMessageDispatcher()
-
WeixinMessageDispatcher
public WeixinMessageDispatcher(WeixinMessageMatcher messageMatcher)
-
-
Method Detail
-
doDispatch
public void doDispatch(io.netty.channel.ChannelHandlerContext context, WeixinRequest request)
对消息进行一系列的处理,包括 拦截、匹配、分发等动作- Parameters:
context
- 上下文环境request
- 微信请求messageTransfer
- 微信消息 @
-
defineMessageKey
protected WeixinMessageKey defineMessageKey(WeixinMessageTransfer messageTransfer, WeixinRequest request)
声明messagekey- Parameters:
messageTransfer
- 基础消息request
- 请求信息- Returns:
-
noHandlerFound
protected void noHandlerFound(io.netty.channel.ChannelHandlerContext context, WeixinRequest request, WeixinMessage message)
未匹配到handler时触发- Parameters:
context
- 上下文环境request
- 微信请求message
- 微信消息
-
getHandlerExecutor
protected MessageHandlerExecutor getHandlerExecutor(io.netty.channel.ChannelHandlerContext context, WeixinRequest request, WeixinMessageKey messageKey, WeixinMessage message, Set<String> nodeNames)
MessageHandlerExecutor- Parameters:
context
- 上下文环境request
- 微信请求messageKey
- 消息的keymessage
- 微信消息nodeNames
- 节点名称集合- Returns:
- MessageHandlerExecutor
- See Also:
@
-
getMessageHandlers
public WeixinMessageHandler[] getMessageHandlers()
获取所有的handler- Returns:
- handler集合
- See Also:
@
-
getMessageInterceptors
public WeixinMessageInterceptor[] getMessageInterceptors()
获取所有的interceptor- Returns:
- interceptor集合
- See Also:
WeixinMessageInterceptor
-
messageRead
protected <M extends WeixinMessage> M messageRead(String message, Class<M> clazz)
jaxb读取微信消息- Parameters:
message
- xml消息clazz
- 消息类型- Returns:
- 消息对象 @
-
getUnmarshaller
protected javax.xml.bind.Unmarshaller getUnmarshaller(Class<? extends WeixinMessage> clazz)
xml消息转换器- Parameters:
clazz
- 消息类型- Returns:
- 消息转换器 @
-
setMessageHandlerList
public void setMessageHandlerList(List<WeixinMessageHandler> messageHandlerList)
-
setMessageInterceptorList
public void setMessageInterceptorList(List<WeixinMessageInterceptor> messageInterceptorList)
-
getMessageHandlerPackages
public String[] getMessageHandlerPackages()
-
getMessageInterceptorPackages
public String[] getMessageInterceptorPackages()
-
setMessageHandlerPackages
public void setMessageHandlerPackages(String... messageHandlerPackages)
-
setMessageInterceptorPackages
public void setMessageInterceptorPackages(String... messageInterceptorPackages)
-
getBeanFactory
public BeanFactory getBeanFactory()
-
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
-
registMessageClass
public void registMessageClass(WeixinMessageKey messageKey, Class<? extends WeixinMessage> messageClass)
-
getMessageMatcher
public WeixinMessageMatcher getMessageMatcher()
-
openAlwaysResponse
public void openAlwaysResponse()
打开总是响应开关,如未匹配到MessageHandler时回复空白消息
-
-