1 package com.zone.weixin4j.interceptor;
2
3 import com.zone.weixin4j.exception.WeixinException;
4 import com.zone.weixin4j.handler.WeixinMessageHandler;
5 import com.zone.weixin4j.request.WeixinMessage;
6 import com.zone.weixin4j.request.WeixinRequest;
7 import com.zone.weixin4j.response.WeixinResponse;
8
9 /**
10 * 微信消息拦截器
11 *
12 * @author jinyu(foxinmy@gmail.com)
13 * @className WeixinMessageInterceptor
14 * @date 2015年5月7日
15 * @see MessageInterceptorAdapter
16 * @since JDK 1.6
17 */
18 public interface WeixinMessageInterceptor {
19
20 /**
21 * 执行handler前
22 *
23 * @param request 微信请求
24 * @param message 微信消息
25 * @param handler 消息处理器
26 * @return 返回true执行下一个拦截器
27 * @throws WeixinException
28 */
29 boolean preHandle(WeixinRequest request,
30 WeixinMessage message, WeixinMessageHandler handler)
31 throws WeixinException;
32
33 /**
34 * 执行handler后
35 *
36 * @param request 微信请求
37 * @param response 微信响应
38 * @param message 微信消息
39 * @param handler 消息处理器
40 * @throws WeixinException
41 */
42 void postHandle(WeixinRequest request,
43 WeixinResponse response, WeixinMessage message,
44 WeixinMessageHandler handler) throws WeixinException;
45
46 /**
47 * 全部执行后
48 *
49 * @param request 微信请求
50 * @param message 微信消息
51 * @param handler 消息处理器
52 * @param exception 执行异常
53 * @throws WeixinException
54 */
55 void afterCompletion(WeixinRequest request,
56 WeixinResponse response, WeixinMessage message,
57 WeixinMessageHandler handler, Exception exception)
58 throws WeixinException;
59
60 /**
61 * 用于匹配到多个MessageHandler时权重降序排列,数字越大优先级越高
62 *
63 * @return 权重
64 */
65 int weight();
66 }