1 22 package org.jboss.resource.adapter.quartz.inflow; 23 24 import org.quartz.SchedulerConfigException; 25 26 import javax.resource.spi.work.Work ; 27 import javax.resource.spi.work.WorkException ; 28 import javax.resource.spi.work.WorkManager ; 29 30 41 public class JBossQuartzThreadPool implements org.quartz.spi.ThreadPool 42 { 43 private int poolSize = Integer.MAX_VALUE; 44 45 private WorkManager workManager; 46 47 public void initialize() throws SchedulerConfigException 48 { 49 workManager = QuartzResourceAdapter.getConfigTimeWorkManager(); 50 } 51 52 57 public int getPoolSize() 58 { 59 return poolSize; 60 } 61 62 public boolean runInThread(Runnable runnable) 63 { 64 try 65 { 66 WorkWrapper workWrapper = new WorkWrapper(runnable); 67 workManager.doWork(workWrapper); 68 return true; 69 } 70 catch (WorkException e) 71 { 72 return false; 73 } 74 } 75 76 79 public void shutdown(boolean waitForJobsToComplete) 80 { 81 } 82 83 86 public void setPoolSize(int poolSize) 87 { 88 this.poolSize = poolSize; 89 } 90 91 private class WorkWrapper implements Work 92 { 93 94 private Runnable delegate; 95 96 public WorkWrapper(Runnable delegate) 97 { 98 this.delegate = delegate; 99 } 100 101 public void run() 102 { 103 delegate.run(); 104 } 105 106 public void release() 107 { 108 } 109 110 } 111 112 } 113 | Popular Tags |