Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations of LobHandler #4666

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ private void registerJobRepository(BeanDefinitionRegistry registry, EnableBatchP
beanDefinitionBuilder.addPropertyReference("serializer", executionContextSerializerRef);
}

String lobHandlerRef = batchAnnotation.lobHandlerRef();
if (registry.containsBeanDefinition(lobHandlerRef)) {
beanDefinitionBuilder.addPropertyReference("lobHandler", lobHandlerRef);
}

String conversionServiceRef = batchAnnotation.conversionServiceRef();
if (registry.containsBeanDefinition(conversionServiceRef)) {
beanDefinitionBuilder.addPropertyReference("conversionService", conversionServiceRef);
Expand Down Expand Up @@ -168,11 +163,6 @@ private void registerJobExplorer(BeanDefinitionRegistry registry, EnableBatchPro
beanDefinitionBuilder.addPropertyReference("serializer", executionContextSerializerRef);
}

String lobHandlerRef = batchAnnotation.lobHandlerRef();
if (registry.containsBeanDefinition(lobHandlerRef)) {
beanDefinitionBuilder.addPropertyReference("lobHandler", lobHandlerRef);
}

String conversionServiceRef = batchAnnotation.conversionServiceRef();
if (registry.containsBeanDefinition(conversionServiceRef)) {
beanDefinitionBuilder.addPropertyReference("conversionService", conversionServiceRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,6 @@
*/
String jobKeyGeneratorRef() default "jobKeyGenerator";

/**
* The large object handler to use in job repository and job explorer.
* @return the bean name of the lob handler to use. Defaults to {@literal lobHandler}.
*/
String lobHandlerRef() default "lobHandler";

/**
* The type of large objects.
* @return the type of large objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.Types;

import javax.sql.DataSource;

import org.springframework.batch.core.DefaultJobKeyGenerator;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobKeyGenerator;
Expand Down Expand Up @@ -65,8 +63,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.MetaDataAccessException;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Isolation;

Expand Down Expand Up @@ -135,7 +131,6 @@ public JobRepository jobRepository() throws BatchConfigurationException {
jobRepositoryFactoryBean.setSerializer(getExecutionContextSerializer());
jobRepositoryFactoryBean.setConversionService(getConversionService());
jobRepositoryFactoryBean.setJdbcOperations(getJdbcOperations());
jobRepositoryFactoryBean.setLobHandler(getLobHandler());
jobRepositoryFactoryBean.setCharset(getCharset());
jobRepositoryFactoryBean.setMaxVarCharLength(getMaxVarCharLength());
jobRepositoryFactoryBean.setIsolationLevelForCreateEnum(getIsolationLevelForCreate());
Expand Down Expand Up @@ -189,7 +184,6 @@ public JobExplorer jobExplorer() throws BatchConfigurationException {
jobExplorerFactoryBean.setJobKeyGenerator(getJobKeyGenerator());
jobExplorerFactoryBean.setCharset(getCharset());
jobExplorerFactoryBean.setTablePrefix(getTablePrefix());
jobExplorerFactoryBean.setLobHandler(getLobHandler());
jobExplorerFactoryBean.setConversionService(getConversionService());
jobExplorerFactoryBean.setSerializer(getExecutionContextSerializer());
try {
Expand Down Expand Up @@ -385,16 +379,6 @@ protected Charset getCharset() {
return StandardCharsets.UTF_8;
}

/**
* A special handler for large objects. The default is usually fine, except for some
* (usually older) versions of Oracle.
* @return the {@link LobHandler} to use
*
*/
protected LobHandler getLobHandler() {
return new DefaultLobHandler();
}

/**
* Return the {@link JdbcOperations}. If this property is not overridden, a new
* {@link JdbcTemplate} will be created for the configured data source by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit

String maxVarCharLength = element.getAttribute("max-varchar-length");

String lobHandler = element.getAttribute("lob-handler");

String serializer = element.getAttribute("serializer");

String conversionService = element.getAttribute("conversion-service");
Expand All @@ -97,9 +95,6 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit
if (StringUtils.hasText(tablePrefix)) {
builder.addPropertyValue("tablePrefix", tablePrefix);
}
if (StringUtils.hasText(lobHandler)) {
builder.addPropertyReference("lobHandler", lobHandler);
}
if (StringUtils.hasText(maxVarCharLength)) {
builder.addPropertyValue("maxVarCharLength", maxVarCharLength);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import javax.sql.DataSource;

import org.springframework.batch.core.DefaultJobKeyGenerator;
import org.springframework.batch.core.JobKeyGenerator;
import org.springframework.batch.core.converter.DateToStringConverter;
Expand All @@ -42,7 +40,6 @@
import org.springframework.batch.core.repository.dao.JobExecutionDao;
import org.springframework.batch.core.repository.dao.JobInstanceDao;
import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.convert.support.ConfigurableConversionService;
Expand All @@ -51,7 +48,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -81,8 +77,6 @@ protected long getNextKey() {

private JobKeyGenerator jobKeyGenerator;

private LobHandler lobHandler;

private ExecutionContextSerializer serializer;

private Charset charset = StandardCharsets.UTF_8;
Expand Down Expand Up @@ -138,16 +132,6 @@ public void setJobKeyGenerator(JobKeyGenerator jobKeyGenerator) {
this.jobKeyGenerator = jobKeyGenerator;
}

/**
* The lob handler to use when saving {@link ExecutionContext} instances. Defaults to
* {@code null}, which works for most databases.
* @param lobHandler Large object handler for saving an
* {@link org.springframework.batch.item.ExecutionContext}.
*/
public void setLobHandler(LobHandler lobHandler) {
this.lobHandler = lobHandler;
}

/**
* Sets the {@link Charset} to use when deserializing the execution context. Defaults
* to "UTF-8". Must not be {@code null}.
Expand Down Expand Up @@ -208,7 +192,6 @@ public void afterPropertiesSet() throws Exception {
protected ExecutionContextDao createExecutionContextDao() throws Exception {
JdbcExecutionContextDao dao = new JdbcExecutionContextDao();
dao.setJdbcTemplate(jdbcOperations);
dao.setLobHandler(lobHandler);
dao.setTablePrefix(tablePrefix);
dao.setSerializer(serializer);
dao.setCharset(charset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import javax.sql.rowset.serial.SerialClob;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.core.serializer.Serializer;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -110,8 +109,6 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem

private int shortContextLength = DEFAULT_MAX_VARCHAR_LENGTH;

private LobHandler lobHandler = new DefaultLobHandler();

private ExecutionContextSerializer serializer = new DefaultExecutionContextSerializer();

private final Lock lock = new ReentrantLock();
Expand Down Expand Up @@ -268,10 +265,6 @@ public void deleteExecutionContext(StepExecution stepExecution) {
getJdbcTemplate().update(getQuery(DELETE_STEP_EXECUTION_CONTEXT), stepExecution.getId());
}

public void setLobHandler(LobHandler lobHandler) {
this.lobHandler = lobHandler;
}

@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
Expand Down Expand Up @@ -301,7 +294,7 @@ private void persistSerializedContext(final Long executionId, String serializedC
getJdbcTemplate().update(getQuery(sql), ps -> {
ps.setString(1, shortContext);
if (longContext != null) {
lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
ps.setClob(2, new SerialClob(longContext.toCharArray()));
}
else {
ps.setNull(2, getClobTypeToUse());
Expand Down Expand Up @@ -337,7 +330,7 @@ public void setValues(PreparedStatement ps, int i) throws SQLException {
}
ps.setString(1, shortContext);
if (longContext != null) {
lobHandler.getLobCreator().setClobAsString(ps, 2, longContext);
ps.setClob(2, new SerialClob(longContext.toCharArray()));
}
else {
ps.setNull(2, getClobTypeToUse());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -95,8 +93,6 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i

private int maxVarCharLengthForShortContext = AbstractJdbcBatchMetadataDao.DEFAULT_SHORT_CONTEXT_LENGTH;

private LobHandler lobHandler;

private ExecutionContextSerializer serializer;

private Integer clobType;
Expand Down Expand Up @@ -124,18 +120,6 @@ public void setSerializer(ExecutionContextSerializer serializer) {
this.serializer = serializer;
}

/**
* A 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.
* @param lobHandler the {@link LobHandler} to set
*
* @see LobHandler
*/
public void setLobHandler(LobHandler lobHandler) {
this.lobHandler = lobHandler;
}

/**
* 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
Expand Down Expand Up @@ -275,10 +259,6 @@ public void afterPropertiesSet() throws Exception {
}
}

if (lobHandler == null && databaseType.equalsIgnoreCase(DatabaseType.ORACLE.toString())) {
lobHandler = new DefaultLobHandler();
}

if (serializer == null) {
serializer = new DefaultExecutionContextSerializer();
}
Expand Down Expand Up @@ -354,10 +334,6 @@ protected ExecutionContextDao createExecutionContextDao() throws Exception {
dao.setSerializer(serializer);
dao.setCharset(charset);

if (lobHandler != null) {
dao.setLobHandler(lobHandler);
}

dao.afterPropertiesSet();
dao.setShortContextLength(this.maxVarCharLengthForShortContext);
return dao;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,6 @@ ref" is not required, and only needs to be specified explicitly
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="lob-handler" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to the lob handler (optional). Only override if using Oracle and
the database type is not being detected for some reason.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.jdbc.support.lob.LobHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down Expand Up @@ -1288,4 +1275,4 @@ ref" is not required, and only needs to be specified explicitly
<xsd:restriction base="xsd:string" />
</xsd:simpleType>

</xsd:schema>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,6 @@ ref" is not required, and only needs to be specified explicitly
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="lob-handler" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to the lob handler (optional). Only override if using Oracle and
the database type is not being detected for some reason.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.jdbc.support.lob.LobHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<xsd:attribute name="data-source" type="xsd:string" default="dataSource">
<xsd:annotation>
<xsd:documentation source="java:javax.sql.DataSource"><![CDATA[
The bean name of the DataSource that is to be used. This attribute
The bean name of the DataSource that is to be used. This attribute
is not required, and only needs to be specified explicitly
if the bean name of the desired DataSource is not 'dataSource'.
]]></xsd:documentation>
Expand All @@ -198,7 +198,7 @@
<xsd:attribute name="jdbc-operations" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.jdbc.core.JdbcOperations"><![CDATA[
The bean name of the JdbcOperations that is to be used. This attribute
The bean name of the JdbcOperations that is to be used. This attribute
is not required, if it is not set a org.springframework.jdbc.core.JdbcTemplate will be
created for the configured data-source.
]]></xsd:documentation>
Expand Down Expand Up @@ -264,19 +264,6 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="lob-handler" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to the lob handler (optional). Only override if using Oracle and
the database type is not being detected for some reason.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.jdbc.support.lob.LobHandler" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down
Loading