Class JobOperatorService

  • All Implemented Interfaces:
    javax.batch.operations.JobOperator, org.jboss.msc.Service, org.jboss.msc.service.Service<javax.batch.operations.JobOperator>, org.jboss.msc.value.Value<javax.batch.operations.JobOperator>

    public class JobOperatorService
    extends org.jberet.operations.AbstractJobOperator
    implements javax.batch.operations.JobOperator, org.jboss.msc.service.Service<javax.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
    • Method Detail

      • 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
        Specified by:
        start in interface org.jboss.msc.service.Service<javax.batch.operations.JobOperator>
        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
        Specified by:
        stop in interface org.jboss.msc.service.Service<javax.batch.operations.JobOperator>
      • getBatchEnvironment

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

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

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

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

        public List<Long> getRunningExecutions​(String jobName)
                                        throws javax.batch.operations.NoSuchJobException,
                                               javax.batch.operations.JobSecurityException
        Specified by:
        getRunningExecutions in interface javax.batch.operations.JobOperator
        Overrides:
        getRunningExecutions in class org.jberet.operations.AbstractJobOperator
        Throws:
        javax.batch.operations.NoSuchJobException
        javax.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 javax.batch.operations.NoSuchJobExecutionException,
                                        javax.batch.operations.JobSecurityException
        Specified by:
        getParameters in interface javax.batch.operations.JobOperator
        Overrides:
        getParameters in class org.jberet.operations.AbstractJobOperator
        Throws:
        javax.batch.operations.NoSuchJobExecutionException
        javax.batch.operations.JobSecurityException
      • start

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

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

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

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

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

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

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

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

        public Set<String> getAllJobNames()
      • getBatchConfigurationInjector

        public org.jboss.msc.value.InjectedValue<BatchConfiguration> getBatchConfigurationInjector()
      • getBatchEnvironmentInjector

        public org.jboss.msc.inject.Injector<SecurityAwareBatchEnvironment> getBatchEnvironmentInjector()
        Set the batch environment to use for setting up the correct class loader for delegating executions.
        Returns:
        the injector used to inject the value in
      • getExecutorServiceInjector

        public org.jboss.msc.inject.Injector<ExecutorService> getExecutorServiceInjector()
      • getSuspendControllerInjector

        public org.jboss.msc.value.InjectedValue<org.jboss.as.server.suspend.SuspendController> getSuspendControllerInjector()
      • allowMissingJob

        public 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