FileDocCategorySizeDatePackage
QuartzResourceAdapter.javaAPI DocJBoss 4.2.14329Fri Jul 13 21:01:14 BST 2007org.jboss.resource.adapter.quartz.inflow

QuartzResourceAdapter

public class QuartzResourceAdapter extends Object implements javax.resource.spi.ResourceAdapter
The QuartzResourceAdapter.
author
Bill Burke
version
$Revision: 57189 $

Fields Summary
private static Logger
log
private Scheduler
sched
Constructors Summary
Methods Summary
public voidendpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory, javax.resource.spi.ActivationSpec spec)

      log.debug("endpointActivation, spec="+spec);
      QuartzActivationSpec quartzSpec = (QuartzActivationSpec) spec;

      // allocate instance of endpoint to figure out its endpoint interface
      Class clazz = QuartzJob.class;
      MessageEndpoint tmpMe = endpointFactory.createEndpoint(null);
      if (tmpMe instanceof StatefulJob) clazz = StatefulQuartzJob.class;
      tmpMe.release();

      try
      {
         JobDetail jobDetail = new JobDetail(quartzSpec.getJobName(), quartzSpec.getJobGroup(), clazz, quartzSpec.getVolatility(), quartzSpec.getDurable(), quartzSpec.getRecoverable());
         jobDetail.getJobDataMap().setAllowsTransientData(true);
         jobDetail.getJobDataMap().put("endpointFactory", endpointFactory);
         log.debug("adding job: " + quartzSpec);
         CronTrigger trigger = new CronTrigger(quartzSpec.getTriggerName(), quartzSpec.getTriggerGroup(), quartzSpec.getCronTrigger());
         sched.scheduleJob(jobDetail, trigger);
      }
      catch (Exception e)
      {
         log.error(e);
         throw new ResourceException(e);
      }
   
public voidendpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory, javax.resource.spi.ActivationSpec spec)

      QuartzActivationSpec quartzSpec = (QuartzActivationSpec) spec;
      try
      {
         log.debug("****endpointDeactivation: " + quartzSpec);
         sched.deleteJob(quartzSpec.getJobName(), quartzSpec.getJobGroup());
      }
      catch (SchedulerException e)
      {
         throw new RuntimeException(e);
      }
   
public javax.transaction.xa.XAResource[]getXAResources(javax.resource.spi.ActivationSpec[] specs)

      return new XAResource[0];
   
public voidstart(javax.resource.spi.BootstrapContext ctx)


        
   
      
      log.info("start quartz!!!");
      
      SchedulerFactory sf = new StdSchedulerFactory();
      try
      {
         sched = sf.getScheduler();
         sched.start();
      }
      catch (SchedulerException e)
      {
         throw new ResourceAdapterInternalException(e);
      }
   
public voidstop()

      log.debug("stop");
      try
      {
         sched.shutdown(true);
      }
      catch (SchedulerException e)
      {
         throw new RuntimeException(e);
      }