Class JobService

java.lang.Object
edu.ucsb.cs156.frontiers.services.jobs.JobService

@Service public class JobService extends Object
  • Constructor Details

    • JobService

      public JobService()
  • Method Details

    • runAsJob

      public Job runAsJob(JobContextConsumer jobFunction)
    • runJobAsync

      @Async @Transactional public void runJobAsync(Job job, JobContextConsumer jobFunction)
      Runs a job asynchronously.

      This method is annotated with @Transactional because outside of the Spring context, you cannot delete entities that are unmanaged by Hibernate. Adding @Transactional keeps the database session open and allows Hibernate to maintain it's knowledge of the object graph (i.e. the entities)

      To learn more, read about Hibernate and the concept of a Spring Context.

      Note that @Transactional means that if there is an unhandled exception, either every database transactions succeeds, or all of them are rolled back.

      Parameters:
      job -
      jobFunction -
    • getJobLogs

      public String getJobLogs(Long jobId)