コード例 #1
0
 /* (non-Javadoc)
  * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
  */
 public int compare(WxMessageHandlerIfc o1, WxMessageHandlerIfc o2) {
   if (o1.priority() > o2.priority()) {
     return -1;
   } else if (o1.priority() < o2.priority()) {
     return 1;
   } else {
     return 0;
   }
 }
コード例 #2
0
  public WxBaseRespEntity handleMessage(WxBaseMsgEntity msg) {
    List<WxMessageHandlerIfc> handlerList = new ArrayList<WxMessageHandlerIfc>();
    handlerList.addAll(handlers);
    Collections.sort(handlerList, new WxMessageHandlerComparator());

    Map<String, Object> context = new HashMap<String, Object>();
    WxBaseRespEntity result = null;
    for (WxMessageHandlerIfc handler : handlerList) {
      result = handler.handle(msg, context);
    }

    if (result == null) {
      result = defaultResult(msg.getToUserName(), msg.getFromUserName());
    }
    return result;
  }