Sei sulla pagina 1di 2

JobRepository

JobRepository is used for basic CRUD operations of the various persisted domain objects within Spring Batch, such as JobExecution and StepExecution. It is required by many of the major framework features, such as the JobLauncher, Job, and Step. <job-repository id="jobRepository" data-source="dataSourceRevamp" transaction-manager="transactionManager" isolation-level-for-create="READ_UNCOMMITTED" table-prefix="BATCH_"/>

JobLauncher
When trying to launch from an HTTP request, a issues arises. In this scenario, the launching needs to be done asynchronously so that the SimpleJobLauncher returns immediately to its caller. This is because it is not good practice to keep an HTTP request open for the amount of time needed by long running processes such as batch. <beans:bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <beans:property name="jobRepository" ref="jobRepository" /> <beans:property name="taskExecutor"> <beans:bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" /> </beans:property> </beans:bean>

JobRegistry
A JobRegistry (and its parent interface JobLocator) is not mandatory, but it can be useful if you want to keep track of which jobs are available in the context. It is also useful for collecting jobs centrally in an application context when they have been created elsewhere (e.g. in child contexts). There is only one implementation provided by the framework <beans:bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" />

JobOperator
JobOperator interface are most useful when used together(the JobRepository provides CRUD operations on the meta-data, and the JobExplorer provides read-only operations on the meta-data) to perform common monitoring tasks such as stopping, restarting, or summarizing a Job, as is commonly done by batch operators. <beans:bean id="jobOperator" class="org.springframework.batch.core.launch.support.SimpleJobOperator"> <beans:property name="jobExplorer" ref="jobExplorer " /> <beans:property name="jobRepository" ref="jobRepository" /> <beans:property name="jobRegistry" ref="jobRegistry" /> <beans:property name="jobLauncher" ref="jobLauncher" /> </beans:bean>

JobExplorer
The most basic need before any advanced features is the ability to query the repository for existing executions. This functionality is provided by the JobExplorer interface

<beans:bean id="jobExplorer" class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"> <beans:property name="dataSource" ref="dataSourceRevamp" /> </beans:bean>

JobRegistryBeanPostProcessor
This is a bean post-processor that can register all jobs as they are created: <beans:bean id="jobRegistryBeanPostProcessor" class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor"> <beans:property name="jobRegistry" ref="jobRegistry" /> </beans:bean>

JobListener
<beans:bean id="stepExecutionListener" class="com.springframework.batch.listener.StepExecutionListener"> <beans:property name="jobOperator" ref="jobOperator" /> </beans:bean>

Potrebbero piacerti anche