1 17 18 package org.apache.geronimo.connector.work.pool; 19 20 import EDU.oswego.cs.dl.util.concurrent.Channel; 21 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor; 22 import org.apache.geronimo.connector.work.WorkerContext; 23 24 30 public class TimedOutPooledExecutor extends PooledExecutor { 31 32 36 public TimedOutPooledExecutor() { 37 setBlockedExecutionHandler(new TimedOutSpinHandler()); 38 } 39 40 47 public TimedOutPooledExecutor(Channel aChannel) { 48 super(aChannel); 49 setBlockedExecutionHandler(new TimedOutSpinHandler()); 50 } 51 52 58 public void execute(Runnable aTask) throws InterruptedException { 59 if (!(aTask instanceof WorkerContext)) { 60 throw new IllegalArgumentException ("Please submit a WorkWrapper."); 61 } 62 super.execute(aTask); 63 } 64 65 71 private class TimedOutSpinHandler 72 implements PooledExecutor.BlockedExecutionHandler { 73 74 77 public boolean blockedAction(Runnable arg0) throws InterruptedException { 78 WorkerContext work = (WorkerContext) arg0; 79 if (!handOff_.offer(arg0, work.getStartTimeout())) { 80 if (work.isTimedOut()) { 82 return false; 83 } 84 return true; 85 } 86 return true; 87 } 88 } 89 } 90 | Popular Tags |