Class DefaultScheduledJobService<P extends ScheduledJob>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.scheduledjob.service.DefaultScheduledJobService<P>
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, ScheduledJobService<P>

public class DefaultScheduledJobService<P extends ScheduledJob> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements ScheduledJobService<P>
Author:
Chad Harchar (charchar)
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultScheduledJobService(ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Deletes the ScheduledJob and removes it from the Scheduler - and any associated Triggers.
    Establish the NotificationStateAware contract for TriggeredJobEventProducer.TYPE.
    executeJob(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Causes the specified ScheduledJob to be executed immediately.
     
    protected com.broadleafcommerce.common.messaging.notification.NotificationManager
     
    protected ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
     
    protected org.springframework.transaction.support.TransactionTemplate
     
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    markJobAsExecuted(String contextId, TimingType timingType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Mark a job as executed via ScheduledJob.isExecuted().
    org.springframework.data.domain.Page<P>
    readAllByName(String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Read a page of job records focusing on name (optional)
    replace(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    protected P
    resetUnmodifiableFieldsToOriginalValues(String id, P scheduledJob, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    void
     
    void
     
    void
    setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate)
     
    void
    setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
    streamAll(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read a stream of all ScheduledJobs in the data store.

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

    getRsqlHelper, readAll, readAll, readAll, readAll

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

    convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

    create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll

    Methods inherited from interface com.broadleafcommerce.scheduledjob.service.ScheduledJobService

    markJobAsExecuted
  • Constructor Details

    • DefaultScheduledJobService

      public DefaultScheduledJobService(ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
  • Method Details

    • streamAll

      @NonNull public Stream<P> streamAll(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ScheduledJobService
      Read a stream of all ScheduledJobs in the data store.
      Specified by:
      streamAll in interface ScheduledJobService<P extends ScheduledJob>
      Parameters:
      contextInfo - context information surrounding multitenant state
      Returns:
      a stream of all ScheduledJobs in the data store
    • readAllByName

      @NonNull public org.springframework.data.domain.Page<P> readAllByName(@Nullable String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ScheduledJobService
      Read a page of job records focusing on name (optional)
      Specified by:
      readAllByName in interface ScheduledJobService<P extends ScheduledJob>
      Parameters:
      name - The name of the job to retrieve (optional)
      filters - Any additional search filters to apply
      page - The configuration for the page of records to retrieve
      context - The fetch view context
      Returns:
      The page of records
    • markJobAsExecuted

      public P markJobAsExecuted(@NonNull String contextId, @NonNull TimingType timingType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ScheduledJobService
      Mark a job as executed via ScheduledJob.isExecuted(). As part of an atomic operation, this method should also set the ScheduledJob.getLastExecuted() field and disable the job via ScheduledJob.isEnabled() if the job is of TimingType.TARGET_DATE. Finally, the NotificationState of type TriggeredJobEventProducer.TYPE should be configured to start the resiliency lifecycle. See NotificationState for more information on the fields there related to messaging resiliency.

      If ScheduledJob.isTrackExecutionDetails() is true, a new ScheduledJobExecutionDetail is also created. This is primarily used for tracking the execution details of a scheduledJob

      Specified by:
      markJobAsExecuted in interface ScheduledJobService<P extends ScheduledJob>
      Parameters:
      contextId - The tracking identifier for the scheduled job
      timingType - The type of job (e.g. whether it's recurring cron or single use)
      contextInfo - the contextInfo
      Returns:
      the updated job if found and successfully updated, otherwise null. For example, if another process had already updated the record as being executed, this update would not succeed.
    • replace

      public P replace(@NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      replace in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ScheduledJob>
      Overrides:
      replace in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ScheduledJob>
    • establishTriggerStateIfApplicable

      public P establishTriggerStateIfApplicable(String contextId)
      Description copied from interface: ScheduledJobService
      Establish the NotificationStateAware contract for TriggeredJobEventProducer.TYPE. This should initialize the basic support for a trigger type NotificationState item in the NotificationStateAware.getNotificationStates() list. This state is generally completed during the ScheduledJobService.markJobAsExecuted(String, TimingType) lifecycle.
      Specified by:
      establishTriggerStateIfApplicable in interface ScheduledJobService<P extends ScheduledJob>
      Parameters:
      contextId - The tracking identifier for the scheduled job
      Returns:
      The initialized entity instance
    • executeJob

      public P executeJob(@NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ScheduledJobService
      Causes the specified ScheduledJob to be executed immediately.
      Specified by:
      executeJob in interface ScheduledJobService<P extends ScheduledJob>
      Parameters:
      id - The identifier for the scheduled job
      context - context information surrounding multitenant state
      Returns:
      The job that was executed
    • delete

      public void delete(@NonNull String contextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Deletes the ScheduledJob and removes it from the Scheduler - and any associated Triggers.
      Specified by:
      delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ScheduledJob>
      Overrides:
      delete in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ScheduledJob>
      Parameters:
      contextId - The scheduled job id
      context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
    • resetUnmodifiableFieldsToOriginalValues

      protected P resetUnmodifiableFieldsToOriginalValues(String id, P scheduledJob, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • getRepository

      @NonNull protected ScheduledJobRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ScheduledJob>
    • getNotificationManager

      @NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()
    • setSchedulerService

      @Autowired @Lazy public void setSchedulerService(SchedulerService schedulerService)
    • getSchedulerService

      @NonNull protected SchedulerService getSchedulerService()
    • setTransactionTemplate

      @Autowired @Lazy @Qualifier("scheduledJobTransactionTemplate") public void setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate)
    • getTransactionTemplate

      @NonNull protected org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
    • getExecutionDetailService

      protected ScheduledJobExecutionDetailService<ScheduledJobExecutionDetail> getExecutionDetailService()
    • setExecutionDetailService

      @Autowired public void setExecutionDetailService(ScheduledJobExecutionDetailService<ScheduledJobExecutionDetail> executionDetailService)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)