Package com.zhangwoo.spider.server

Source Code of com.zhangwoo.spider.server.ConversationSaveHandler

package com.zhangwoo.spider.server;

import java.util.List;

import org.apache.log4j.Logger;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

import com.zhangwoo.spider.po.Conversation;
import com.zhangwoo.spider.server.dao.ConversationDao;

public class ConversationSaveHandler extends IoHandlerAdapter {
  private static Logger logger = Logger.getLogger(ConversationSaveHandler.class.getName());

  public void exceptionCaught(IoSession session, Throwable cause)
      throws Exception {
    logger.error("ConversationSaveHandler error ", cause);
  }

  @SuppressWarnings("unchecked")
  public void messageReceived(IoSession session, Object message)
      throws Exception {
    new ConversationDao().save((List<Conversation>) message);
  }

  public static void main(String[] args) {
//    try {
//      BaseDao dao = new BaseDao();
//      List<Object[]> re = dao.query("select hkeys from kvs");
//      System.out.println(re.get(0)[0]);
//    } catch (SQLException e) {
//      // TODO Auto-generated catch block
//      e.printStackTrace();
//    }
  }
}
TOP

Related Classes of com.zhangwoo.spider.server.ConversationSaveHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.