Class JobOperatorService

java.lang.Object
org.jberet.operations.AbstractJobOperator
org.wildfly.extension.batch.jberet.deployment.JobOperatorService
All Implemented Interfaces:
jakarta.batch.operations.JobOperator, org.jboss.msc.Service, org.jboss.msc.service.Service<jakarta.batch.operations.JobOperator>, org.jboss.msc.value.Value<jakarta.batch.operations.JobOperator>

public class JobOperatorService extends org.jberet.operations.AbstractJobOperator implements jakarta.batch.operations.JobOperator, org.jboss.msc.service.Service<jakarta.batch.operations.JobOperator>
A delegating job operator to interact with the batch environment on deployments.

Note that for each method the job name, or derived job name, must exist for the deployment. The allowed job names and job XML descriptor are determined at deployment time.

This implementation does change some of the API's contracts however it's only intended to be used by management resources and operations. Limits the interaction with the jobs to the scope of the deployments jobs. Any behavioral change will be documented.

Author:
James R. Perkins, Richard Opalka
  • Constructor Details

  • Method Details

    • start

      public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
      Specified by:
      start in interface org.jboss.msc.Service
      Throws:
      org.jboss.msc.service.StartException
    • stop

      public void stop(org.jboss.msc.service.StopContext context)
      Specified by:
      stop in interface org.jboss.msc.Service
    • getValue

      public jakarta.batch.operations.JobOperator getValue() throws IllegalStateException, IllegalArgumentException
      Specified by:
      getValue in interface org.jboss.msc.value.Value<jakarta.batch.operations.JobOperator>
      Throws:
      IllegalStateException
      IllegalArgumentException
    • getBatchEnvironment

      public SecurityAwareBatchEnvironment getBatchEnvironment()
      Specified by:
      getBatchEnvironment in class org.jberet.operations.AbstractJobOperator
    • getJobNames

      public Set<String> getJobNames() throws jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobNames in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobNames in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.JobSecurityException
    • getJobInstanceCount

      public int getJobInstanceCount(String jobName) throws jakarta.batch.operations.NoSuchJobException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobInstanceCount in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobInstanceCount in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobException
      jakarta.batch.operations.JobSecurityException
    • getJobInstances

      public List<jakarta.batch.runtime.JobInstance> getJobInstances(String jobName, int start, int count) throws jakarta.batch.operations.NoSuchJobException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobInstances in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobInstances in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobException
      jakarta.batch.operations.JobSecurityException
    • getRunningExecutions

      public List<Long> getRunningExecutions(String jobName) throws jakarta.batch.operations.NoSuchJobException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getRunningExecutions in interface jakarta.batch.operations.JobOperator
      Overrides:
      getRunningExecutions in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobException
      jakarta.batch.operations.JobSecurityException
    • getJobExecutionsByJob

      public List<Long> getJobExecutionsByJob(String jobName)
      Overrides:
      getJobExecutionsByJob in class org.jberet.operations.AbstractJobOperator
    • getParameters

      public Properties getParameters(long executionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getParameters in interface jakarta.batch.operations.JobOperator
      Overrides:
      getParameters in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobSecurityException
    • start

      public long start(String jobXMLName, Properties jobParameters) throws jakarta.batch.operations.JobStartException, jakarta.batch.operations.JobSecurityException
      Specified by:
      start in interface jakarta.batch.operations.JobOperator
      Overrides:
      start in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.JobStartException
      jakarta.batch.operations.JobSecurityException
    • restart

      public long restart(long executionId, Properties restartParameters) throws jakarta.batch.operations.JobExecutionAlreadyCompleteException, jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobExecutionNotMostRecentException, jakarta.batch.operations.JobRestartException, jakarta.batch.operations.JobSecurityException
      Specified by:
      restart in interface jakarta.batch.operations.JobOperator
      Overrides:
      restart in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.JobExecutionAlreadyCompleteException
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobExecutionNotMostRecentException
      jakarta.batch.operations.JobRestartException
      jakarta.batch.operations.JobSecurityException
    • stop

      public void stop(long executionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobExecutionNotRunningException, jakarta.batch.operations.JobSecurityException
      Specified by:
      stop in interface jakarta.batch.operations.JobOperator
      Overrides:
      stop in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobExecutionNotRunningException
      jakarta.batch.operations.JobSecurityException
    • abandon

      public void abandon(long executionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobExecutionIsRunningException, jakarta.batch.operations.JobSecurityException
      Specified by:
      abandon in interface jakarta.batch.operations.JobOperator
      Overrides:
      abandon in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobExecutionIsRunningException
      jakarta.batch.operations.JobSecurityException
    • getJobInstance

      public jakarta.batch.runtime.JobInstance getJobInstance(long executionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobInstance in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobInstance in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobSecurityException
    • getJobExecutions

      public List<jakarta.batch.runtime.JobExecution> getJobExecutions(jakarta.batch.runtime.JobInstance instance) throws jakarta.batch.operations.NoSuchJobInstanceException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobExecutions in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobExecutions in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobInstanceException
      jakarta.batch.operations.JobSecurityException
    • getJobExecution

      public jakarta.batch.runtime.JobExecution getJobExecution(long executionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getJobExecution in interface jakarta.batch.operations.JobOperator
      Overrides:
      getJobExecution in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobSecurityException
    • getStepExecutions

      public List<jakarta.batch.runtime.StepExecution> getStepExecutions(long jobExecutionId) throws jakarta.batch.operations.NoSuchJobExecutionException, jakarta.batch.operations.JobSecurityException
      Specified by:
      getStepExecutions in interface jakarta.batch.operations.JobOperator
      Overrides:
      getStepExecutions in class org.jberet.operations.AbstractJobOperator
      Throws:
      jakarta.batch.operations.NoSuchJobExecutionException
      jakarta.batch.operations.JobSecurityException
    • getJobXmlNames

      public Collection<String> getJobXmlNames()
    • getJobXmlNames

      public Collection<String> getJobXmlNames(String jobName)
    • getAllJobNames

      public Set<String> getAllJobNames()
    • allowMissingJob

      default <T> T allowMissingJob(Supplier<T> supplier, T defaultValue)
      Allows safe execution of a method catching any NoSuchJobException thrown. If the exception is thrown the default value is returned, otherwise the value from the supplier is returned.
      Type Parameters:
      T - the return type
      Parameters:
      supplier - the supplier for the value
      defaultValue - the default value if a NoSuchJobException is thrown
      Returns:
      the value from the supplier or the default value if a NoSuchJobException was thrown