DispatchThinkerTasks.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:1k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core.task.dispatch;
  2. import net.javacoding.jspider.core.Agent;
  3. import net.javacoding.jspider.core.SpiderContext;
  4. import net.javacoding.jspider.core.exception.*;
  5. import net.javacoding.jspider.core.logging.LogFactory;
  6. import net.javacoding.jspider.core.threading.WorkerThreadPool;
  7. /**
  8.  *
  9.  * $Id: DispatchThinkerTasks.java,v 1.6 2003/03/27 17:44:19 vanrogu Exp $
  10.  *
  11.  * @author G黱ther Van Roey
  12.  */
  13. public class DispatchThinkerTasks extends BaseDispatchTaskImpl {
  14.     protected WorkerThreadPool thinkers;
  15.     protected Agent agent;
  16.     protected SpiderContext context;
  17.     public DispatchThinkerTasks(WorkerThreadPool thinkers, SpiderContext context) {
  18.         super(context);
  19.         this.thinkers = thinkers;
  20.         this.agent = context.getAgent();
  21.         this.context = context;
  22.     }
  23.     public void execute() {
  24.         LogFactory.getLog(DispatchThinkerTasks.class).debug("Thinker task dispatcher running ...");
  25.         while (running) {
  26.             try {
  27.                 thinkers.assign(agent.getThinkerTask());
  28.             } catch (NoSuitableItemFoundException e) {
  29.             } catch (SpideringDoneException e) {
  30.                 running = false;
  31.             } catch (TaskAssignmentException e) {
  32.                 // We dealt with all subclasses, so this shouldn't happen !!!
  33.             }
  34.         }
  35.         LogFactory.getLog(DispatchThinkerTasks.class).debug("Thinker task dispatcher dying ...");
  36.     }
  37. }