Class JobOperatorService
- java.lang.Object
-
- org.jberet.operations.AbstractJobOperator
-
- org.wildfly.extension.batch.jberet.deployment.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
-
-
Constructor Summary
Constructors Constructor Description JobOperatorService(Boolean restartJobsOnResume, String deploymentName, WildFlyJobXmlResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Modifier and Type Method Description voidabandon(long executionId)default <T> TallowMissingJob(Supplier<T> supplier, T defaultValue)Allows safe execution of a method catching anyNoSuchJobExceptionthrown.Set<String>getAllJobNames()org.jboss.msc.value.InjectedValue<BatchConfiguration>getBatchConfigurationInjector()SecurityAwareBatchEnvironmentgetBatchEnvironment()org.jboss.msc.inject.Injector<SecurityAwareBatchEnvironment>getBatchEnvironmentInjector()Set the batch environment to use for setting up the correct class loader for delegating executions.org.jboss.msc.inject.Injector<ExecutorService>getExecutorServiceInjector()javax.batch.runtime.JobExecutiongetJobExecution(long executionId)List<javax.batch.runtime.JobExecution>getJobExecutions(javax.batch.runtime.JobInstance instance)List<Long>getJobExecutionsByJob(String jobName)javax.batch.runtime.JobInstancegetJobInstance(long executionId)intgetJobInstanceCount(String jobName)List<javax.batch.runtime.JobInstance>getJobInstances(String jobName, int start, int count)Set<String>getJobNames()Collection<String>getJobXmlNames()Collection<String>getJobXmlNames(String jobName)PropertiesgetParameters(long executionId)List<Long>getRunningExecutions(String jobName)List<javax.batch.runtime.StepExecution>getStepExecutions(long jobExecutionId)org.jboss.msc.value.InjectedValue<org.jboss.as.server.suspend.SuspendController>getSuspendControllerInjector()javax.batch.operations.JobOperatorgetValue()longrestart(long executionId, Properties restartParameters)longstart(String jobXMLName, Properties jobParameters)voidstart(org.jboss.msc.service.StartContext context)voidstop(long executionId)voidstop(org.jboss.msc.service.StopContext context)
-
-
-
Constructor Detail
-
JobOperatorService
public JobOperatorService(Boolean restartJobsOnResume, String deploymentName, WildFlyJobXmlResolver resolver)
-
-
Method Detail
-
start
public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException- Specified by:
startin interfaceorg.jboss.msc.Service- Specified by:
startin interfaceorg.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:
stopin interfaceorg.jboss.msc.Service- Specified by:
stopin interfaceorg.jboss.msc.service.Service<javax.batch.operations.JobOperator>
-
getValue
public javax.batch.operations.JobOperator getValue() throws IllegalStateException, IllegalArgumentException- Specified by:
getValuein interfaceorg.jboss.msc.value.Value<javax.batch.operations.JobOperator>- Throws:
IllegalStateExceptionIllegalArgumentException
-
getBatchEnvironment
public SecurityAwareBatchEnvironment getBatchEnvironment()
- Specified by:
getBatchEnvironmentin classorg.jberet.operations.AbstractJobOperator
-
getJobNames
public Set<String> getJobNames() throws javax.batch.operations.JobSecurityException
- Specified by:
getJobNamesin interfacejavax.batch.operations.JobOperator- Overrides:
getJobNamesin classorg.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:
getJobInstanceCountin interfacejavax.batch.operations.JobOperator- Overrides:
getJobInstanceCountin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExceptionjavax.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:
getJobInstancesin interfacejavax.batch.operations.JobOperator- Overrides:
getJobInstancesin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExceptionjavax.batch.operations.JobSecurityException
-
getRunningExecutions
public List<Long> getRunningExecutions(String jobName) throws javax.batch.operations.NoSuchJobException, javax.batch.operations.JobSecurityException
- Specified by:
getRunningExecutionsin interfacejavax.batch.operations.JobOperator- Overrides:
getRunningExecutionsin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExceptionjavax.batch.operations.JobSecurityException
-
getJobExecutionsByJob
public List<Long> getJobExecutionsByJob(String jobName)
- Overrides:
getJobExecutionsByJobin classorg.jberet.operations.AbstractJobOperator
-
getParameters
public Properties getParameters(long executionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobSecurityException
- Specified by:
getParametersin interfacejavax.batch.operations.JobOperator- Overrides:
getParametersin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobSecurityException
-
start
public long start(String jobXMLName, Properties jobParameters) throws javax.batch.operations.JobStartException, javax.batch.operations.JobSecurityException
- Specified by:
startin interfacejavax.batch.operations.JobOperator- Overrides:
startin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.JobStartExceptionjavax.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:
restartin interfacejavax.batch.operations.JobOperator- Overrides:
restartin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.JobExecutionAlreadyCompleteExceptionjavax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobExecutionNotMostRecentExceptionjavax.batch.operations.JobRestartExceptionjavax.batch.operations.JobSecurityException
-
stop
public void stop(long executionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobExecutionNotRunningException, javax.batch.operations.JobSecurityException- Specified by:
stopin interfacejavax.batch.operations.JobOperator- Overrides:
stopin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobExecutionNotRunningExceptionjavax.batch.operations.JobSecurityException
-
abandon
public void abandon(long executionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobExecutionIsRunningException, javax.batch.operations.JobSecurityException- Specified by:
abandonin interfacejavax.batch.operations.JobOperator- Overrides:
abandonin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobExecutionIsRunningExceptionjavax.batch.operations.JobSecurityException
-
getJobInstance
public javax.batch.runtime.JobInstance getJobInstance(long executionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobSecurityException- Specified by:
getJobInstancein interfacejavax.batch.operations.JobOperator- Overrides:
getJobInstancein classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.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:
getJobExecutionsin interfacejavax.batch.operations.JobOperator- Overrides:
getJobExecutionsin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobInstanceExceptionjavax.batch.operations.JobSecurityException
-
getJobExecution
public javax.batch.runtime.JobExecution getJobExecution(long executionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobSecurityException- Specified by:
getJobExecutionin interfacejavax.batch.operations.JobOperator- Overrides:
getJobExecutionin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobSecurityException
-
getStepExecutions
public List<javax.batch.runtime.StepExecution> getStepExecutions(long jobExecutionId) throws javax.batch.operations.NoSuchJobExecutionException, javax.batch.operations.JobSecurityException
- Specified by:
getStepExecutionsin interfacejavax.batch.operations.JobOperator- Overrides:
getStepExecutionsin classorg.jberet.operations.AbstractJobOperator- Throws:
javax.batch.operations.NoSuchJobExecutionExceptionjavax.batch.operations.JobSecurityException
-
getJobXmlNames
public Collection<String> getJobXmlNames()
-
getJobXmlNames
public Collection<String> getJobXmlNames(String jobName)
-
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 anyNoSuchJobExceptionthrown. 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 valuedefaultValue- the default value if aNoSuchJobExceptionis thrown- Returns:
- the value from the supplier or the default value if a
NoSuchJobExceptionwas thrown
-
-