コード例 #1
1
  public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
      throws ResourceException {
    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, true, false, false);
      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);
    }
  }
コード例 #2
0
 public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
   QuartzActivationSpec quartzSpec = (QuartzActivationSpec) spec;
   try {
     log.debug("****endpointDeactivation: " + quartzSpec);
     sched.deleteJob(quartzSpec.getJobName(), quartzSpec.getJobGroup());
   } catch (SchedulerException e) {
     throw new RuntimeException(e);
   }
 }