Polishing
This commit is contained in:
@@ -28,8 +28,8 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation that marks a method to be scheduled. Exactly one of the
|
* Annotation that marks a method to be scheduled. Exactly one of the
|
||||||
* {@link #cron}, {@link #fixedDelay}, or {@link #fixedRate} attributes must be
|
* {@link #cron}, {@link #fixedDelay}, or {@link #fixedRate} attributes
|
||||||
* specified.
|
* must be specified.
|
||||||
*
|
*
|
||||||
* <p>The annotated method must expect no arguments. It will typically have
|
* <p>The annotated method must expect no arguments. It will typically have
|
||||||
* a {@code void} return type; if not, the returned value will be ignored
|
* a {@code void} return type; if not, the returned value will be ignored
|
||||||
@@ -40,6 +40,12 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
|||||||
* done manually or, more conveniently, through the {@code <task:annotation-driven/>}
|
* done manually or, more conveniently, through the {@code <task:annotation-driven/>}
|
||||||
* XML element or {@link EnableScheduling @EnableScheduling} annotation.
|
* XML element or {@link EnableScheduling @EnableScheduling} annotation.
|
||||||
*
|
*
|
||||||
|
* <p>This annotation can be used as a <em>{@linkplain Repeatable repeatable}</em>
|
||||||
|
* annotation. If several scheduled declarations are found on the same method,
|
||||||
|
* each of them will be processed independently, with a separate trigger firing
|
||||||
|
* for each of them. As a consequence, such co-located schedules may overlap
|
||||||
|
* and execute multiple times in parallel or in immediate succession.
|
||||||
|
*
|
||||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||||
* <em>composed annotations</em> with attribute overrides.
|
* <em>composed annotations</em> with attribute overrides.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -205,8 +205,7 @@ public class GenericConversionService implements ConfigurableConversionService {
|
|||||||
* @param targetType the target type
|
* @param targetType the target type
|
||||||
* @return the converted value
|
* @return the converted value
|
||||||
* @throws ConversionException if a conversion exception occurred
|
* @throws ConversionException if a conversion exception occurred
|
||||||
* @throws IllegalArgumentException if targetType is {@code null},
|
* @throws IllegalArgumentException if targetType is {@code null}
|
||||||
* or sourceType is {@code null} but source is not {@code null}
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object convert(@Nullable Object source, TypeDescriptor targetType) {
|
public Object convert(@Nullable Object source, TypeDescriptor targetType) {
|
||||||
|
|||||||
@@ -445,9 +445,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||||||
logger.debug("Executing SQL query [" + sql + "]");
|
logger.debug("Executing SQL query [" + sql + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Callback to execute the query.
|
||||||
* Callback to execute the query.
|
|
||||||
*/
|
|
||||||
class QueryStatementCallback implements StatementCallback<T>, SqlProvider {
|
class QueryStatementCallback implements StatementCallback<T>, SqlProvider {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -542,9 +540,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||||||
logger.debug("Executing SQL update [" + sql + "]");
|
logger.debug("Executing SQL update [" + sql + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Callback to execute the update statement.
|
||||||
* Callback to execute the update statement.
|
|
||||||
*/
|
|
||||||
class UpdateStatementCallback implements StatementCallback<Integer>, SqlProvider {
|
class UpdateStatementCallback implements StatementCallback<Integer>, SqlProvider {
|
||||||
@Override
|
@Override
|
||||||
public Integer doInStatement(Statement stmt) throws SQLException {
|
public Integer doInStatement(Statement stmt) throws SQLException {
|
||||||
@@ -570,9 +566,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||||||
logger.debug("Executing SQL batch update of " + sql.length + " statements");
|
logger.debug("Executing SQL batch update of " + sql.length + " statements");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Callback to execute the batch update.
|
||||||
* Callback to execute the batch update.
|
|
||||||
*/
|
|
||||||
class BatchUpdateStatementCallback implements StatementCallback<int[]>, SqlProvider {
|
class BatchUpdateStatementCallback implements StatementCallback<int[]>, SqlProvider {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -1376,7 +1370,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(param.isResultsParameter())) {
|
if (!param.isResultsParameter()) {
|
||||||
sqlColIndex++;
|
sqlColIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -31,6 +31,8 @@ import org.springframework.util.Assert;
|
|||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 2.5.6
|
* @since 2.5.6
|
||||||
|
* @see #doTranslate
|
||||||
|
* @see #setFallbackTranslator
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExceptionTranslator {
|
public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExceptionTranslator {
|
||||||
|
|
||||||
@@ -42,8 +44,8 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default SQL state fallback translator
|
* Set the fallback translator to use when this translator cannot find a
|
||||||
* (typically a {@link SQLStateSQLExceptionTranslator}).
|
* specific match itself.
|
||||||
*/
|
*/
|
||||||
public void setFallbackTranslator(@Nullable SQLExceptionTranslator fallback) {
|
public void setFallbackTranslator(@Nullable SQLExceptionTranslator fallback) {
|
||||||
this.fallbackTranslator = fallback;
|
this.fallbackTranslator = fallback;
|
||||||
@@ -51,6 +53,7 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the fallback exception translator, if any.
|
* Return the fallback exception translator, if any.
|
||||||
|
* @see #setFallbackTranslator
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public SQLExceptionTranslator getFallbackTranslator() {
|
public SQLExceptionTranslator getFallbackTranslator() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -75,8 +75,6 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
|
|||||||
private static final int MESSAGE_SQL_THROWABLE_CONSTRUCTOR = 4;
|
private static final int MESSAGE_SQL_THROWABLE_CONSTRUCTOR = 4;
|
||||||
private static final int MESSAGE_SQL_SQLEX_CONSTRUCTOR = 5;
|
private static final int MESSAGE_SQL_SQLEX_CONSTRUCTOR = 5;
|
||||||
|
|
||||||
|
|
||||||
/** Error codes used by this translator. */
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private SingletonSupplier<SQLErrorCodes> sqlErrorCodes;
|
private SingletonSupplier<SQLErrorCodes> sqlErrorCodes;
|
||||||
|
|
||||||
@@ -194,9 +192,9 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
|
|||||||
if (sqlErrorCodes != null) {
|
if (sqlErrorCodes != null) {
|
||||||
SQLExceptionTranslator customTranslator = sqlErrorCodes.getCustomSqlExceptionTranslator();
|
SQLExceptionTranslator customTranslator = sqlErrorCodes.getCustomSqlExceptionTranslator();
|
||||||
if (customTranslator != null) {
|
if (customTranslator != null) {
|
||||||
DataAccessException customDex = customTranslator.translate(task, sql, sqlEx);
|
dae = customTranslator.translate(task, sql, sqlEx);
|
||||||
if (customDex != null) {
|
if (dae != null) {
|
||||||
return customDex;
|
return dae;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,11 +222,10 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
|
|||||||
for (CustomSQLErrorCodesTranslation customTranslation : customTranslations) {
|
for (CustomSQLErrorCodesTranslation customTranslation : customTranslations) {
|
||||||
if (Arrays.binarySearch(customTranslation.getErrorCodes(), errorCode) >= 0 &&
|
if (Arrays.binarySearch(customTranslation.getErrorCodes(), errorCode) >= 0 &&
|
||||||
customTranslation.getExceptionClass() != null) {
|
customTranslation.getExceptionClass() != null) {
|
||||||
DataAccessException customException = createCustomException(
|
dae = createCustomException(task, sql, sqlEx, customTranslation.getExceptionClass());
|
||||||
task, sql, sqlEx, customTranslation.getExceptionClass());
|
if (dae != null) {
|
||||||
if (customException != null) {
|
|
||||||
logTranslation(task, sql, sqlEx, true);
|
logTranslation(task, sql, sqlEx, true);
|
||||||
return customException;
|
return dae;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user