mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Polishing
This commit is contained in:
@@ -263,7 +263,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the query timeout for statements that this JdbcTemplate executes.
|
||||
* Set the query timeout (seconds) for statements that this JdbcTemplate executes.
|
||||
* <p>Default is -1, indicating to use the JDBC driver's default
|
||||
* (i.e. to not pass a specific query timeout setting on the driver).
|
||||
* <p>Note: Any timeout specified here will be overridden by the remaining
|
||||
@@ -276,7 +276,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the query timeout for statements that this JdbcTemplate executes.
|
||||
* Return the query timeout (seconds) for statements that this JdbcTemplate executes.
|
||||
*/
|
||||
public int getQueryTimeout() {
|
||||
return this.queryTimeout;
|
||||
@@ -422,7 +422,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final String sql) throws DataAccessException {
|
||||
public void execute(String sql) throws DataAccessException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL statement [" + sql + "]");
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T query(final String sql, final ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
public <T> T query(String sql, ResultSetExtractor<T> rse) throws DataAccessException {
|
||||
Assert.notNull(sql, "SQL must not be null");
|
||||
Assert.notNull(rse, "ResultSetExtractor must not be null");
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -542,7 +542,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(final String sql) throws DataAccessException {
|
||||
public int update(String sql) throws DataAccessException {
|
||||
Assert.notNull(sql, "SQL must not be null");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL update [" + sql + "]");
|
||||
@@ -568,7 +568,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] batchUpdate(final String... sql) throws DataAccessException {
|
||||
public int[] batchUpdate(String... sql) throws DataAccessException {
|
||||
Assert.notEmpty(sql, "SQL array must not be empty");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL batch update of " + sql.length + " statements");
|
||||
@@ -714,7 +714,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
*/
|
||||
@Nullable
|
||||
public <T> T query(
|
||||
PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss, final ResultSetExtractor<T> rse)
|
||||
PreparedStatementCreator psc, @Nullable PreparedStatementSetter pss, ResultSetExtractor<T> rse)
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(rse, "ResultSetExtractor must not be null");
|
||||
@@ -964,7 +964,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
return result(query(sql, args, new SqlRowSetResultSetExtractor()));
|
||||
}
|
||||
|
||||
protected int update(final PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss)
|
||||
protected int update(PreparedStatementCreator psc, @Nullable PreparedStatementSetter pss)
|
||||
throws DataAccessException {
|
||||
|
||||
logger.debug("Executing prepared SQL update");
|
||||
@@ -994,7 +994,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(final PreparedStatementCreator psc, final KeyHolder generatedKeyHolder)
|
||||
public int update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(generatedKeyHolder, "KeyHolder must not be null");
|
||||
@@ -1027,8 +1027,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] batchUpdate(final PreparedStatementCreator psc, final BatchPreparedStatementSetter pss,
|
||||
final KeyHolder generatedKeyHolder) throws DataAccessException {
|
||||
public int[] batchUpdate(PreparedStatementCreator psc, BatchPreparedStatementSetter pss,
|
||||
KeyHolder generatedKeyHolder) throws DataAccessException {
|
||||
|
||||
int[] result = execute(psc, getPreparedStatementCallback(pss, generatedKeyHolder));
|
||||
|
||||
@@ -1037,7 +1037,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] batchUpdate(String sql, final BatchPreparedStatementSetter pss) throws DataAccessException {
|
||||
public int[] batchUpdate(String sql, BatchPreparedStatementSetter pss) throws DataAccessException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL batch update [" + sql + "]");
|
||||
}
|
||||
@@ -1057,7 +1057,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] batchUpdate(String sql, List<Object[]> batchArgs, final int[] argTypes) throws DataAccessException {
|
||||
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException {
|
||||
if (batchArgs.isEmpty()) {
|
||||
return new int[0];
|
||||
}
|
||||
@@ -1094,8 +1094,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> int[][] batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize,
|
||||
final ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
|
||||
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
|
||||
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Executing SQL batch update [" + sql + "] with a batch size of " + batchSize);
|
||||
@@ -1209,9 +1209,9 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
public Map<String, Object> call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
|
||||
throws DataAccessException {
|
||||
|
||||
final List<SqlParameter> updateCountParameters = new ArrayList<>();
|
||||
final List<SqlParameter> resultSetParameters = new ArrayList<>();
|
||||
final List<SqlParameter> callParameters = new ArrayList<>();
|
||||
List<SqlParameter> updateCountParameters = new ArrayList<>();
|
||||
List<SqlParameter> resultSetParameters = new ArrayList<>();
|
||||
List<SqlParameter> callParameters = new ArrayList<>();
|
||||
|
||||
for (SqlParameter parameter : declaredParameters) {
|
||||
if (parameter.isResultsParameter()) {
|
||||
@@ -1261,7 +1261,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
int rsIndex = 0;
|
||||
int updateIndex = 0;
|
||||
boolean moreResults;
|
||||
if (!this.skipResultsProcessing) {
|
||||
if (!isSkipResultsProcessing()) {
|
||||
do {
|
||||
if (updateCount == -1) {
|
||||
if (resultSetParameters != null && resultSetParameters.size() > rsIndex) {
|
||||
@@ -1270,7 +1270,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
rsIndex++;
|
||||
}
|
||||
else {
|
||||
if (!this.skipUndeclaredResults) {
|
||||
if (!isSkipUndeclaredResults()) {
|
||||
String rsName = RETURN_RESULT_SET_PREFIX + (rsIndex + 1);
|
||||
SqlReturnResultSet undeclaredRsParam = new SqlReturnResultSet(rsName, getColumnMapRowMapper());
|
||||
if (logger.isTraceEnabled()) {
|
||||
@@ -1289,7 +1289,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
updateIndex++;
|
||||
}
|
||||
else {
|
||||
if (!this.skipUndeclaredResults) {
|
||||
if (!isSkipUndeclaredResults()) {
|
||||
String undeclaredName = RETURN_UPDATE_COUNT_PREFIX + (updateIndex + 1);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Added default SqlReturnUpdateCount parameter named '" + undeclaredName + "'");
|
||||
|
||||
@@ -47,10 +47,9 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* Helper class that simplifies synchronous JMS access code.
|
||||
*
|
||||
* <p>If you want to use dynamic destination creation, you must specify
|
||||
* the type of JMS destination to create, using the "pubSubDomain" property.
|
||||
* For other operations, this is not necessary. Point-to-Point (Queues) is the default
|
||||
* domain.
|
||||
* <p>If you want to use dynamic destination creation, you must specify the type of
|
||||
* JMS destination to create, using the "pubSubDomain" property. For other operations,
|
||||
* this is not necessary. Point-to-Point (Queues) is the default domain.
|
||||
*
|
||||
* <p>Default settings for JMS Sessions are "not transacted" and "auto-acknowledge".
|
||||
* As defined by the Jakarta EE specification, the transaction and acknowledgement
|
||||
@@ -105,7 +104,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
@Nullable
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
|
||||
private boolean messageIdEnabled = true;
|
||||
|
||||
private boolean messageTimestampEnabled = true;
|
||||
@@ -116,7 +114,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
|
||||
private long deliveryDelay = -1;
|
||||
|
||||
|
||||
private boolean explicitQosEnabled = false;
|
||||
|
||||
private int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
|
||||
@@ -151,11 +148,8 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the default implementations for the template's strategies:
|
||||
* DynamicDestinationResolver and SimpleMessageConverter.
|
||||
* @see #setDestinationResolver
|
||||
* Initialize the default implementations for the template's strategies.
|
||||
* @see #setMessageConverter
|
||||
* @see org.springframework.jms.support.destination.DynamicDestinationResolver
|
||||
* @see org.springframework.jms.support.converter.SimpleMessageConverter
|
||||
*/
|
||||
protected void initDefaultStrategies() {
|
||||
@@ -262,7 +256,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether message IDs are enabled. Default is "true".
|
||||
* <p>This is only a hint to the JMS producer.
|
||||
@@ -352,7 +345,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
return this.deliveryDelay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if the QOS values (deliveryMode, priority, timeToLive)
|
||||
* should be used for sending a message.
|
||||
@@ -454,7 +446,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
* Set the time-to-live of the message when sending.
|
||||
* <p>Since a default value may be defined administratively,
|
||||
* this is only used when "isExplicitQosEnabled" equals "true".
|
||||
* @param timeToLive the message's lifetime (in milliseconds)
|
||||
* @param timeToLive the message lifetime (in milliseconds)
|
||||
* @see #isExplicitQosEnabled
|
||||
* @see jakarta.jms.Message#DEFAULT_TIME_TO_LIVE
|
||||
* @see jakarta.jms.MessageProducer#send(jakarta.jms.Message, int, int, long)
|
||||
@@ -472,7 +464,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
|
||||
/**
|
||||
* Configure the {@link ObservationRegistry} to use for recording JMS observations.
|
||||
* @param observationRegistry the observation registry to use.
|
||||
* @param observationRegistry the observation registry to use
|
||||
* @since 6.1
|
||||
* @see io.micrometer.jakarta9.instrument.jms.JmsInstrumentation
|
||||
*/
|
||||
@@ -480,6 +472,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
this.observationRegistry = observationRegistry;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// JmsOperations execute methods
|
||||
//---------------------------------------------------------------------------------------
|
||||
@@ -699,8 +692,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAndSend(
|
||||
Destination destination, Object message, MessagePostProcessor postProcessor)
|
||||
public void convertAndSend(Destination destination, Object message, MessagePostProcessor postProcessor)
|
||||
throws JmsException {
|
||||
|
||||
send(destination, session -> {
|
||||
@@ -710,8 +702,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAndSend(
|
||||
String destinationName, Object message, MessagePostProcessor postProcessor)
|
||||
public void convertAndSend(String destinationName, Object message, MessagePostProcessor postProcessor)
|
||||
throws JmsException {
|
||||
|
||||
send(destinationName, session -> {
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public abstract class JmsDestinationAccessor extends JmsAccessor {
|
||||
* @see org.springframework.jms.support.destination.JndiDestinationResolver
|
||||
*/
|
||||
public void setDestinationResolver(DestinationResolver destinationResolver) {
|
||||
Assert.notNull(destinationResolver, "'destinationResolver' must not be null");
|
||||
Assert.notNull(destinationResolver, "DestinationResolver must not be null");
|
||||
this.destinationResolver = destinationResolver;
|
||||
}
|
||||
|
||||
|
||||
+22
-24
@@ -123,10 +123,6 @@ public class MessageHeaderAccessor {
|
||||
@Nullable
|
||||
private IdGenerator idGenerator;
|
||||
|
||||
private MessageHeaderAccessor(@Nullable MessageHeaders headers) {
|
||||
this.headers = new MutableMessageHeaders(headers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A constructor to create new headers.
|
||||
@@ -143,23 +139,8 @@ public class MessageHeaderAccessor {
|
||||
this(message != null ? message.getHeaders() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance from a plain {@link Map}.
|
||||
* @param map the raw headers
|
||||
* @since 6.2
|
||||
*/
|
||||
public static MessageHeaderAccessor fromMap(@Nullable Map<String, Object> map) {
|
||||
return fromMessageHeaders(new MessageHeaders(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance from an existing {@link MessageHeaders} instance.
|
||||
* @param headers the headers
|
||||
* @since 6.2
|
||||
*/
|
||||
public static MessageHeaderAccessor fromMessageHeaders(@Nullable MessageHeaders headers) {
|
||||
return new MessageHeaderAccessor(headers);
|
||||
private MessageHeaderAccessor(@Nullable MessageHeaders headers) {
|
||||
this.headers = new MutableMessageHeaders(headers);
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +168,7 @@ public class MessageHeaderAccessor {
|
||||
* <p>When modifications are complete use {@link #setImmutable()} to prevent
|
||||
* further changes. The intended use case for this mechanism is initialization
|
||||
* of a Message within a single thread.
|
||||
* <p>By default this is set to {@code false}.
|
||||
* <p>By default, this is set to {@code false}.
|
||||
* @since 4.1
|
||||
*/
|
||||
public void setLeaveMutable(boolean leaveMutable) {
|
||||
@@ -576,10 +557,27 @@ public class MessageHeaderAccessor {
|
||||
|
||||
// Static factory methods
|
||||
|
||||
/**
|
||||
* Create an instance from a plain {@link Map}.
|
||||
* @param map the raw headers
|
||||
* @since 6.2
|
||||
*/
|
||||
public static MessageHeaderAccessor fromMap(@Nullable Map<String, Object> map) {
|
||||
return fromMessageHeaders(new MessageHeaders(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance from an existing {@link MessageHeaders} instance.
|
||||
* @param headers the headers
|
||||
* @since 6.2
|
||||
*/
|
||||
public static MessageHeaderAccessor fromMessageHeaders(@Nullable MessageHeaders headers) {
|
||||
return new MessageHeaderAccessor(headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original {@code MessageHeaderAccessor} used to create the headers
|
||||
* of the given {@code Message}, or {@code null} if that's not available or if
|
||||
* its type does not match the required type.
|
||||
* of the given {@code Message}, or {@code null} if that's not available.
|
||||
* <p>This is for cases where the existence of an accessor is strongly expected
|
||||
* (followed up with an assertion) or where an accessor will be created otherwise.
|
||||
* @param message the message to get an accessor for
|
||||
|
||||
Reference in New Issue
Block a user