[JBoss-dev] [Fwd: Re: [Jboss-cvs] JBossAS SVN: r55353 -, trunk/connector/src/main/org/jboss/resource/adapter/quartz/inflow]

Ales Justin ales.justin at gmail.com
Mon Aug 7 16:37:28 EDT 2006


 Fixed this accordingly to JBAS-1792:

package org.jboss.resource.adapter.quartz.inflow;

import org.quartz.SchedulerConfigException;

import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
import javax.resource.spi.work.WorkManager;

/**
 * Thread pool used to fire Quartz Jobs.
 * <p/>
 * Using BootstrapContext's workManager thread pool.
 * No dependency outside this rar or JCA.
 *
 * @see http://jira.jboss.com/jira/browse/JBAS-1792
 * @see quartz.properties
 *
 * @author <a href="mailto:ales.justin at gmail.com" <ales.justin at gmail.com>>Ales
Justin</a>
 */
public class JBossQuartzThreadPool implements org.quartz.spi.ThreadPool
{
   private int poolSize = Integer.MAX_VALUE;

   private WorkManager workManager;

   public void initialize() throws SchedulerConfigException
   {
      workManager = QuartzResourceAdapter.getConfigTimeWorkManager();
   }

   /**
    * Currently this method is only used in metadata lookup.
    * Which is has no further use.
    * How to provide better estimate?
    */
   public int getPoolSize()
   {
      return poolSize;
   }

   public boolean runInThread(Runnable runnable)
   {
      try
      {
         WorkWrapper workWrapper = new WorkWrapper(runnable);
         workManager.doWork(workWrapper);
         return true;
      }
      catch (WorkException e)
      {
         return false;
      }
   }

   /**
    * No shutdown impl - workManager is shutdown by itself.
    */
   public void shutdown(boolean waitForJobsToComplete)
   {
   }

   /**
    * Just in case we want to set pool size.
    */
   public void setPoolSize(int poolSize)
   {
      this.poolSize = poolSize;
   }

   private class WorkWrapper implements Work
   {

      private Runnable delegate;

      public WorkWrapper(Runnable delegate)
      {
         this.delegate = delegate;
      }

      public void run()
      {
         delegate.run();
      }

      public void release()
      {
      }

   }

}

Better?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-development/attachments/20060807/bad0ffc5/attachment.html 


More information about the jboss-development mailing list