Class JobRepositoryFactoryBean
java.lang.Object
org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<JobRepository>
,org.springframework.beans.factory.InitializingBean
public class JobRepositoryFactoryBean
extends AbstractJobRepositoryFactoryBean
implements org.springframework.beans.factory.InitializingBean
A
FactoryBean
that automates the creation of a SimpleJobRepository
using JDBC DAO implementations which persist batch metadata in database. Requires the
user to describe what kind of database they are using.- Author:
- Ben Hale, Lucas Ward, Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Field Summary
FieldsFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected ExecutionContextDao
protected JobExecutionDao
protected JobInstanceDao
protected StepExecutionDao
void
setCharset
(Charset charset) Set theCharset
to use when serializing/deserializing the execution context.void
setClobType
(int type) void
setConversionService
(org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use in the job repository.void
setDatabaseType
(String dbType) Sets the database type.void
setDataSource
(DataSource dataSource) Public setter for theDataSource
.void
setIncrementerFactory
(DataFieldMaxValueIncrementerFactory incrementerFactory) void
setJdbcOperations
(org.springframework.jdbc.core.JdbcOperations jdbcOperations) Public setter for theJdbcOperations
.void
setJobKeyGenerator
(JobKeyGenerator jobKeyGenerator) * Sets the generator for creating the key used in identifying unique {link JobInstance} objectsvoid
setLobHandler
(org.springframework.jdbc.support.lob.LobHandler lobHandler) Deprecated, for removal: This API element is subject to removal in a future version.Since 5.2 with no replacement.void
setMaxVarCharLength
(int maxVarCharLength) Public setter for the length of long string columns in database.void
setMaxVarCharLengthForExitMessage
(int maxVarCharLengthForExitMessage) Public setter for the length of the exit message in bothJdbcJobExecutionDao
andJdbcStepExecutionDao
.void
setMaxVarCharLengthForShortContext
(int maxVarCharLengthForShortContext) Public setter for the length of short context string column in database.void
setSerializer
(ExecutionContextSerializer serializer) A custom implementation of theExecutionContextSerializer
.void
setTablePrefix
(String tablePrefix) Sets the table prefix for all the batch meta-data tables.Methods inherited from class org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean
getObject, getObjectType, getTransactionManager, isSingleton, setIsolationLevelForCreate, setIsolationLevelForCreateEnum, setTransactionAttributeSource, setTransactionManager, setValidateTransactionState
-
Field Details
-
logger
protected static final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
JobRepositoryFactoryBean
public JobRepositoryFactoryBean()
-
-
Method Details
-
setClobType
public void setClobType(int type) - Parameters:
type
- a value from theTypes
class to indicate the type to use for a CLOB
-
setSerializer
A custom implementation of theExecutionContextSerializer
. The default, if not injected, is theDefaultExecutionContextSerializer
.- Parameters:
serializer
- used to serialize/deserializeExecutionContext
- See Also:
-
setLobHandler
@Deprecated(since="5.2.0", forRemoval=true) public void setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler) Deprecated, for removal: This API element is subject to removal in a future version.Since 5.2 with no replacement. Scheduled for removal in v6A special handler for large objects. The default is usually fine, except for some (usually older) versions of Oracle. The default is determined from the data base type.- Parameters:
lobHandler
- theLobHandler
to set- See Also:
-
LobHandler
-
setMaxVarCharLength
public void setMaxVarCharLength(int maxVarCharLength) Public setter for the length of long string columns in database. Do not set this if you haven't modified the schema. Note this value will be used for the exit message in bothJdbcJobExecutionDao
andJdbcStepExecutionDao
and also the short version of the execution context inJdbcExecutionContextDao
. If you want to use separate values for exit message and short context, then usesetMaxVarCharLengthForExitMessage(int)
andsetMaxVarCharLengthForShortContext(int)
. For databases with multi-byte character sets this number can be smaller (by up to a factor of 2 for 2-byte characters) than the declaration of the column length in the DDL for the tables.- Parameters:
maxVarCharLength
- the exitMessageLength to set
-
setMaxVarCharLengthForShortContext
public void setMaxVarCharLengthForShortContext(int maxVarCharLengthForShortContext) Public setter for the length of short context string column in database. Do not set this if you haven't modified the schema. For databases with multi-byte character sets this number can be smaller (by up to a factor of 2 for 2-byte characters) than the declaration of the column length in the DDL for the tables. Defaults toAbstractJdbcBatchMetadataDao.DEFAULT_SHORT_CONTEXT_LENGTH
- Parameters:
maxVarCharLengthForShortContext
- the short context length to set- Since:
- 5.1
-
setMaxVarCharLengthForExitMessage
public void setMaxVarCharLengthForExitMessage(int maxVarCharLengthForExitMessage) Public setter for the length of the exit message in bothJdbcJobExecutionDao
andJdbcStepExecutionDao
. Do not set this if you haven't modified the schema. For databases with multi-byte character sets this number can be smaller (by up to a factor of 2 for 2-byte characters) than the declaration of the column length in the DDL for the tables. Defaults toAbstractJdbcBatchMetadataDao.DEFAULT_EXIT_MESSAGE_LENGTH
.- Parameters:
maxVarCharLengthForExitMessage
- the exitMessageLength to set- Since:
- 5.1
-
setDataSource
Public setter for theDataSource
.- Parameters:
dataSource
- aDataSource
-
setJdbcOperations
public void setJdbcOperations(org.springframework.jdbc.core.JdbcOperations jdbcOperations) Public setter for theJdbcOperations
. If this property is not set explicitly, a newJdbcTemplate
will be created for the configured DataSource by default.- Parameters:
jdbcOperations
- aJdbcOperations
-
setDatabaseType
Sets the database type.- Parameters:
dbType
- as specified byDefaultDataFieldMaxValueIncrementerFactory
-
setTablePrefix
Sets the table prefix for all the batch meta-data tables.- Parameters:
tablePrefix
- prefix prepended to batch meta-data tables
-
setIncrementerFactory
-
setJobKeyGenerator
* Sets the generator for creating the key used in identifying unique {link JobInstance} objects- Parameters:
jobKeyGenerator
- aJobKeyGenerator
- Since:
- 5.1
-
setCharset
Set theCharset
to use when serializing/deserializing the execution context. Defaults to "UTF-8". Must not benull
.- Parameters:
charset
- to use when serializing/deserializing the execution context.- Since:
- 5.0
- See Also:
-
setConversionService
public void setConversionService(@NonNull org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use in the job repository. This service is used to convert job parameters from String literal to typed values and vice versa.- Parameters:
conversionService
- the conversion service to use- Since:
- 5.0
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in classAbstractJobRepositoryFactoryBean
- Throws:
Exception
-
createJobInstanceDao
- Specified by:
createJobInstanceDao
in classAbstractJobRepositoryFactoryBean
- Returns:
- fully configured
JobInstanceDao
implementation. - Throws:
Exception
- thrown if error occurs creating JobInstanceDao.
-
createJobExecutionDao
- Specified by:
createJobExecutionDao
in classAbstractJobRepositoryFactoryBean
- Returns:
- fully configured
JobExecutionDao
implementation. - Throws:
Exception
- thrown if error occurs creating JobExecutionDao.
-
createStepExecutionDao
- Specified by:
createStepExecutionDao
in classAbstractJobRepositoryFactoryBean
- Returns:
- fully configured
StepExecutionDao
implementation. - Throws:
Exception
- thrown if error occurs creating StepExecutionDao.
-
createExecutionContextDao
- Specified by:
createExecutionContextDao
in classAbstractJobRepositoryFactoryBean
- Returns:
- fully configured
ExecutionContextDao
implementation. - Throws:
Exception
- thrown if error occurs creating ExecutionContextDao.
-