1 package net.javacoding.jspider.core.task.dispatch; 2 3 4 import net.javacoding.jspider.core.Agent; 5 import net.javacoding.jspider.core.SpiderContext; 6 import net.javacoding.jspider.core.exception.*; 7 import net.javacoding.jspider.core.logging.LogFactory; 8 import net.javacoding.jspider.core.threading.WorkerThreadPool; 9 10 11 17 public class DispatchThinkerTasks extends BaseDispatchTaskImpl { 18 19 protected WorkerThreadPool thinkers; 20 protected Agent agent; 21 protected SpiderContext context; 22 23 public DispatchThinkerTasks(WorkerThreadPool thinkers, SpiderContext context) { 24 super(context); 25 this.thinkers = thinkers; 26 this.agent = context.getAgent(); 27 this.context = context; 28 } 29 30 public void execute() { 31 LogFactory.getLog(DispatchThinkerTasks.class).debug("Thinker task dispatcher running ..."); 32 while (running) { 33 try { 34 thinkers.assign(agent.getThinkerTask()); 35 } catch (NoSuitableItemFoundException e) { 36 } catch (SpideringDoneException e) { 37 running = false; 38 } catch (TaskAssignmentException e) { 39 } 41 } 42 LogFactory.getLog(DispatchThinkerTasks.class).debug("Thinker task dispatcher dying ..."); 43 } 44 } 45 | Popular Tags |