1 18 23 24 package org.apache.roller.business.runnable; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 import org.apache.roller.model.Roller; 29 import org.apache.roller.model.RollerFactory; 30 31 32 37 public class WorkerThread extends Thread { 38 39 private static Log mLogger = LogFactory.getLog(WorkerThread.class); 40 41 String id = null; 42 Job job = null; 43 44 45 48 public WorkerThread(String id) { 49 this.id = id; 50 } 51 52 53 56 public WorkerThread(String id, Job job) { 57 this.id = id; 58 this.job = job; 59 } 60 61 62 67 public void run() { 68 69 if (this.job != null) { 71 try { 73 this.job.execute(); 74 } catch(Throwable t) { 75 mLogger.error("Error executing job. "+ 77 "Worker = "+this.id+", "+ 78 "Job = "+this.job.getClass().getName(), t); 79 } 80 81 Roller roller = RollerFactory.getRoller(); 83 roller.release(); 84 } 85 86 } 87 88 89 92 public void setJob(Job newJob) { 93 mLogger.debug("NEW JOB: "+newJob.getClass().getName()); 94 95 this.job = newJob; 97 } 98 99 } 100 | Popular Tags |