Class DefaultQuartzJob

java.lang.Object
com.broadleafcommerce.scheduledjob.service.DefaultQuartzJob
All Implemented Interfaces:
org.quartz.Job

public class DefaultQuartzJob extends Object implements org.quartz.Job
A Quartz Job that gets executed when the target date or cron expression for the quartz scheduler is hit. This uses Quartz's JobExecutionContext to retrieve services on which to execute the job against, such as firing a message and updating the ScheduledJob in the database.
Author:
Chad Harchar (charchar), Jeff Fischer
  • Constructor Details

    • DefaultQuartzJob

      public DefaultQuartzJob()
  • Method Details

    • execute

      public void execute(org.quartz.JobExecutionContext context)
      Specified by:
      execute in interface org.quartz.Job
    • sendNotification

      public void sendNotification(com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.Trackable notificationStateAware)
      Notify the system of the scheduled job trigger via the TriggeredJobEventProducer.
      Parameters:
      notificationManager - The NotificationManager instance responsible for TriggeredJobEventProducer messaging
      repository - the NotificationStateRepository-implementing scheduled job repository
      notificationStateAware - the persisted-domain instance of the scheduled job for which to notify
    • markExecuted

      @Nullable @Deprecated(forRemoval=true) protected com.broadleafcommerce.data.tracking.core.Trackable markExecuted(ScheduledJob scheduledJob, ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Establish the job as having been executed and also mark the record with NotificationState for messaging resiliency related to the job trigger message.

      Deprecated in favor of markExecuted(ScheduledJob, ScheduledJobService) instead

      Parameters:
      scheduledJob - The job entity
      repository - the NotificationStateRepository-implementing scheduled job repository
      Returns:
      an updated job if updated, otherwise null
    • markExecuted

      @Nullable protected ScheduledJob markExecuted(@NonNull @NonNull ScheduledJob scheduledJob, @NonNull @NonNull ScheduledJobService<ScheduledJob> scheduledJobService)
      Establish the job as having been executed. This also creates a ScheduledJobExecutionDetail to track its execution details if ScheduledJob.isTrackExecutionDetails() is true.

      This also mark the record with NotificationState for messaging resiliency related to the job trigger message.

      Parameters:
      scheduledJob - The job entity
      scheduledJobService - the ScheduledJobService
      Returns:
      an updated job if updated, otherwise null