Class AbstractJob

  • All Implemented Interfaces:
    org.quartz.InterruptableJob, org.quartz.Job
    Direct Known Subclasses:
    BaseJob

    public abstract class AbstractJob
    extends Object
    implements org.quartz.Job, org.quartz.InterruptableJob
    Provides an abstract Quartz Job class.
    Since:
    4.3.4
    • Field Detail

      • SPRING_CONTEXT

        public static final String SPRING_CONTEXT
        The schedulder context path for the application servlet context.
        See Also:
        Constant Field Values
      • SERVLET_CONTEXT

        public static final String SERVLET_CONTEXT
        The scheduler context path for the application servlet context.
        See Also:
        Constant Field Values
      • JOB_CONTEXT_PARAM

        public static final String JOB_CONTEXT_PARAM
        The Job execution context data map paramter name.
        See Also:
        Constant Field Values
      • JOB_GROUP_BACKGROUND

        public static final String JOB_GROUP_BACKGROUND
        The job group for background jobs that are not to be managed in the management console
        See Also:
        Constant Field Values
      • JOB_GROUP_MEMORY

        public static final String JOB_GROUP_MEMORY
        The job group for in memory jobs that are not to be managed in the management console
        See Also:
        Constant Field Values
      • MANAGER_LISTENERS

        protected static final List MANAGER_LISTENERS
      • logExecution

        protected boolean logExecution
        Log the job execution.
    • Constructor Detail

      • AbstractJob

        public AbstractJob()
    • Method Detail

      • executeJob

        public abstract void executeJob()
        Subclasses should override this method to provide their functionality.

        A DataContext object will be bound to the thread executing this task. Any uncommitted changes to the DataContext will be automatically rolled back when this method completes.

      • getContext

        public org.quartz.JobExecutionContext getContext()
        Return the Quartz JobExecutionContext.
        Returns:
        the Quartz JobExecutionContext
      • getContextParam

        public String getContextParam()
        Return the "JobContextParam" value configured for the Scheduled Job.
        Returns:
        the "JobContextParam" value configured for the Scheduled Job.
      • getDataContext

        public org.apache.cayenne.access.DataContext getDataContext()
        Return the thread local DataContext.
        Returns:
        the thread local DataContext
      • isInterrupted

        public boolean isInterrupted()
        Return true if the job has been manually stopped.
        Returns:
        true if the job has been manually stopped
      • interrupt

        public void interrupt()
                       throws org.quartz.UnableToInterruptJobException
        Called by the Scheduler when a user interrupts the job.
        Specified by:
        interrupt in interface org.quartz.InterruptableJob
        Throws:
        org.quartz.UnableToInterruptJobException - if there is an exception while interrupting the job.
        See Also:
        InterruptableJob.interrupt()
      • getErrorLogService

        public ErrorLogService getErrorLogService()
        Returns:
        the error log service.
        Since:
        4.3.4
      • getLogger

        public org.slf4j.Logger getLogger()
        Return the object logger.
        Returns:
        the object logger
      • getServletContext

        public ServletContext getServletContext()
        Return the application servlet context.
        Returns:
        the application servlet context
      • execute

        public final void execute​(org.quartz.JobExecutionContext context)
                           throws org.quartz.JobExecutionException
        Called by the Scheduler when a Trigger fires that is associated with the Job.
        Specified by:
        execute in interface org.quartz.Job
        Parameters:
        context - the job execute context
        Throws:
        org.quartz.JobExecutionException - if there is an exception while executing the job.
        See Also:
        Job.execute(JobExecutionContext)
      • logException

        public ErrorLog logException​(Throwable error)
        Log the exception to the ErrorLog if an error occurs performing the job. Subclasses can override this method to provide customized error logging behavior.
        Parameters:
        error - the exception to log (required)
        Returns:
        the new ErrorLog record