Polishing
This commit is contained in:
@@ -46,7 +46,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
public CannotLoadBeanClassException(
|
||||
String resourceDescription, String beanName, String beanClassName, ClassNotFoundException cause) {
|
||||
|
||||
super("Cannot find class [" + String.valueOf(beanClassName) + "] for bean with name '" + beanName + "'" +
|
||||
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
this.beanName = beanName;
|
||||
@@ -64,7 +64,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
public CannotLoadBeanClassException(
|
||||
String resourceDescription, String beanName, String beanClassName, LinkageError cause) {
|
||||
|
||||
super("Error loading class [" + String.valueOf(beanClassName) + "] for bean with name '" + beanName + "'" +
|
||||
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||
(resourceDescription != null ? " defined in " + resourceDescription : "") +
|
||||
": problem with class file or dependent class", cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,6 +55,7 @@ public class CallableStatementCreatorFactory {
|
||||
/**
|
||||
* Create a new factory. Will need to add parameters via the
|
||||
* {@link #addParameter} method or have no parameters.
|
||||
* @param callString the SQL call string
|
||||
*/
|
||||
public CallableStatementCreatorFactory(String callString) {
|
||||
this.callString = callString;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,7 +56,7 @@ public class PreparedStatementCreatorFactory {
|
||||
|
||||
private boolean returnGeneratedKeys = false;
|
||||
|
||||
private String[] generatedKeysColumnNames = null;
|
||||
private String[] generatedKeysColumnNames;
|
||||
|
||||
private NativeJdbcExtractor nativeJdbcExtractor;
|
||||
|
||||
@@ -64,6 +64,7 @@ public class PreparedStatementCreatorFactory {
|
||||
/**
|
||||
* Create a new factory. Will need to add parameters via the
|
||||
* {@link #addParameter} method or have no parameters.
|
||||
* @param sql the SQL statement to execute
|
||||
*/
|
||||
public PreparedStatementCreatorFactory(String sql) {
|
||||
this.sql = sql;
|
||||
@@ -72,7 +73,7 @@ public class PreparedStatementCreatorFactory {
|
||||
|
||||
/**
|
||||
* Create a new factory with the given SQL and JDBC types.
|
||||
* @param sql SQL to execute
|
||||
* @param sql the SQL statement to execute
|
||||
* @param types int array of JDBC types
|
||||
*/
|
||||
public PreparedStatementCreatorFactory(String sql, int... types) {
|
||||
@@ -82,9 +83,8 @@ public class PreparedStatementCreatorFactory {
|
||||
|
||||
/**
|
||||
* Create a new factory with the given SQL and parameters.
|
||||
* @param sql SQL
|
||||
* @param sql the SQL statement to execute
|
||||
* @param declaredParameters list of {@link SqlParameter} objects
|
||||
* @see SqlParameter
|
||||
*/
|
||||
public PreparedStatementCreatorFactory(String sql, List<SqlParameter> declaredParameters) {
|
||||
this.sql = sql;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -104,8 +104,8 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
|
||||
|
||||
/**
|
||||
* Expose the classic Spring JdbcTemplate to allow invocation of
|
||||
* less commonly used methods.
|
||||
* Expose the classic Spring JdbcTemplate operations to allow invocation
|
||||
* of less commonly used methods.
|
||||
*/
|
||||
@Override
|
||||
public JdbcOperations getJdbcOperations() {
|
||||
@@ -329,12 +329,14 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
getParsedSql(sql), batchArgs, getJdbcOperations());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a PreparedStatementCreator based on the given SQL and named parameters.
|
||||
* <p>Note: Not used for the {@code update} variant with generated key handling.
|
||||
* @param sql SQL to execute
|
||||
* Build a {@link PreparedStatementCreator} based on the given SQL and named parameters.
|
||||
* <p>Note: Directly called from all {@code query} variants.
|
||||
* Not used for the {@code update} variant with generated key handling.
|
||||
* @param sql the SQL statement to execute
|
||||
* @param paramSource container of arguments to bind
|
||||
* @return the corresponding PreparedStatementCreator
|
||||
* @return the corresponding {@link PreparedStatementCreator}
|
||||
*/
|
||||
protected PreparedStatementCreator getPreparedStatementCreator(String sql, SqlParameterSource paramSource) {
|
||||
ParsedSql parsedSql = getParsedSql(sql);
|
||||
@@ -347,9 +349,8 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
|
||||
/**
|
||||
* Obtain a parsed representation of the given SQL statement.
|
||||
* <p>The default implementation uses an LRU cache with an upper limit
|
||||
* of 256 entries.
|
||||
* @param sql the original SQL
|
||||
* <p>The default implementation uses an LRU cache with an upper limit of 256 entries.
|
||||
* @param sql the original SQL statement
|
||||
* @return a representation of the parsed SQL statement
|
||||
*/
|
||||
protected ParsedSql getParsedSql(String sql) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
* @param userRegistry the registry, never {@code null}
|
||||
*/
|
||||
public DefaultUserDestinationResolver(SimpUserRegistry userRegistry) {
|
||||
Assert.notNull(userRegistry, "'userRegistry' must not be null");
|
||||
Assert.notNull(userRegistry, "SimpUserRegistry must not be null");
|
||||
this.userRegistry = userRegistry;
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
* @param prefix the prefix to use
|
||||
*/
|
||||
public void setUserDestinationPrefix(String prefix) {
|
||||
Assert.hasText(prefix, "prefix must not be empty");
|
||||
this.prefix = prefix.endsWith("/") ? prefix : prefix + "/";
|
||||
Assert.hasText(prefix, "Prefix must not be empty");
|
||||
this.prefix = (prefix.endsWith("/") ? prefix : prefix + "/");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,11 +101,11 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
* Use this property to indicate whether the leading slash from translated
|
||||
* user destinations should be removed or not. This depends on the
|
||||
* destination prefixes the message broker is configured with.
|
||||
* <p>By default this is set to {@code false}, i.e. "do not change the
|
||||
* target destination", although
|
||||
* <p>By default this is set to {@code false}, i.e.
|
||||
* "do not change the target destination", although
|
||||
* {@link org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration
|
||||
* AbstractMessageBrokerConfiguration} may change that to {@code true} if
|
||||
* the configured destinations do not have a leading slash.
|
||||
* AbstractMessageBrokerConfiguration} may change that to {@code true}
|
||||
* if the configured destinations do not have a leading slash.
|
||||
* @param remove whether to remove the leading slash
|
||||
* @since 4.3.14
|
||||
*/
|
||||
@@ -115,6 +115,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
|
||||
/**
|
||||
* Whether to remove the leading slash from target destinations.
|
||||
* @since 4.3.14
|
||||
*/
|
||||
public boolean isRemoveLeadingSlash() {
|
||||
return this.removeLeadingSlash;
|
||||
@@ -198,18 +199,18 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
Principal principal = SimpMessageHeaderAccessor.getUser(headers);
|
||||
String user = (principal != null ? principal.getName() : null);
|
||||
Set<String> sessionIds = Collections.singleton(sessionId);
|
||||
return new ParseResult(sourceDestination, actualDestination, sourceDestination,
|
||||
sessionIds, user);
|
||||
return new ParseResult(sourceDestination, actualDestination, sourceDestination, sessionIds, user);
|
||||
}
|
||||
|
||||
private ParseResult parseMessage(MessageHeaders headers, String sourceDestination) {
|
||||
private ParseResult parseMessage(MessageHeaders headers, String sourceDest) {
|
||||
int prefixEnd = this.prefix.length();
|
||||
int userEnd = sourceDestination.indexOf('/', prefixEnd);
|
||||
int userEnd = sourceDest.indexOf('/', prefixEnd);
|
||||
Assert.isTrue(userEnd > 0, "Expected destination pattern \"/user/{userId}/**\"");
|
||||
String actualDestination = sourceDestination.substring(userEnd);
|
||||
String subscribeDestination = this.prefix.substring(0, prefixEnd - 1) + actualDestination;
|
||||
String userName = sourceDestination.substring(prefixEnd, userEnd);
|
||||
String actualDest = sourceDest.substring(userEnd);
|
||||
String subscribeDest = this.prefix.substring(0, prefixEnd - 1) + actualDest;
|
||||
String userName = sourceDest.substring(prefixEnd, userEnd);
|
||||
userName = StringUtils.replace(userName, "%2F", "/");
|
||||
|
||||
String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
|
||||
Set<String> sessionIds;
|
||||
if (userName.equals(sessionId)) {
|
||||
@@ -219,11 +220,11 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
else {
|
||||
sessionIds = getSessionIdsByUser(userName, sessionId);
|
||||
}
|
||||
|
||||
if (isRemoveLeadingSlash()) {
|
||||
actualDestination = actualDestination.substring(1);
|
||||
actualDest = actualDest.substring(1);
|
||||
}
|
||||
return new ParseResult(sourceDestination, actualDestination, subscribeDestination,
|
||||
sessionIds, userName);
|
||||
return new ParseResult(sourceDest, actualDest, subscribeDest, sessionIds, userName);
|
||||
}
|
||||
|
||||
private Set<String> getSessionIdsByUser(String userName, String sessionId) {
|
||||
@@ -288,7 +289,6 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
|
||||
private final String user;
|
||||
|
||||
|
||||
public ParseResult(String sourceDest, String actualDest, String subscribeDest,
|
||||
Set<String> sessionIds, String user) {
|
||||
|
||||
@@ -299,7 +299,6 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
public String getSourceDestination() {
|
||||
return this.sourceDestination;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UnknownHttpStatusCodeException extends RestClientResponseException
|
||||
public UnknownHttpStatusCodeException(int rawStatusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
|
||||
super("Unknown status code [" + String.valueOf(rawStatusCode) + "]" + " " + statusText,
|
||||
super("Unknown status code [" + rawStatusCode + "]" + " " + statusText,
|
||||
rawStatusCode, statusText, responseHeaders, responseBody, responseCharset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user