Polishing

This commit is contained in:
Juergen Hoeller 2015-02-10 19:30:59 +01:00
parent 7585be85f3
commit 058714b03a
10 changed files with 36 additions and 42 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 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.
@ -394,6 +394,8 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
@Override @Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
throws IllegalAccessException, InstantiationException, IOException { throws IllegalAccessException, InstantiationException, IOException {
// Special handling of default encoding
if (format.equals("java.properties")) { if (format.equals("java.properties")) {
String bundleName = toBundleName(baseName, locale); String bundleName = toBundleName(baseName, locale);
final String resourceName = toResourceName(bundleName, "properties"); final String resourceName = toResourceName(bundleName, "properties");
@ -441,6 +443,7 @@ public class ResourceBundleMessageSource extends AbstractMessageSource implement
} }
} }
else { else {
// Delegate handling of "java.class" format to standard Control
return super.newBundle(baseName, locale, format, loader, reload); return super.newBundle(baseName, locale, format, loader, reload);
} }
} }

View File

@ -45,8 +45,8 @@ public class AlternativeJdkIdGenerator implements IdGenerator {
} }
@Override
public UUID generateId() { public UUID generateId() {
byte[] randomBytes = new byte[16]; byte[] randomBytes = new byte[16];
this.random.nextBytes(randomBytes); this.random.nextBytes(randomBytes);

View File

@ -27,7 +27,7 @@ import java.util.UUID;
*/ */
public class JdkIdGenerator implements IdGenerator { public class JdkIdGenerator implements IdGenerator {
@Override
public UUID generateId() { public UUID generateId() {
return UUID.randomUUID(); return UUID.randomUUID();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 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.
@ -42,23 +42,23 @@ public abstract class AbstractMethodArgumentResolutionException extends Messagin
/** /**
* Create a new instance providing the invalid {@code MethodParameter} and * Create a new instance providing the invalid {@code MethodParameter} and
* a prepared description. Sub-classes should prepend the description with * a prepared description. Subclasses should prepend the description with
* the help of {@link #getMethodParamMessage(org.springframework.core.MethodParameter)}. * the help of {@link #getMethodParamMessage(org.springframework.core.MethodParameter)}.
*/ */
protected AbstractMethodArgumentResolutionException(Message<?> message, protected AbstractMethodArgumentResolutionException(Message<?> message, MethodParameter param, String description) {
MethodParameter parameter, String description) {
super(message, description); super(message, description);
this.parameter = parameter; this.parameter = param;
} }
/** /**
* Return the MethodParameter that was rejected. * Return the MethodParameter that was rejected.
*/ */
public MethodParameter getMethodParameter() { public final MethodParameter getMethodParameter() {
return this.parameter; return this.parameter;
} }
protected static String getMethodParamMessage(MethodParameter param) { protected static String getMethodParamMessage(MethodParameter param) {
return new StringBuilder("Could not resolve method parameter at index ") return new StringBuilder("Could not resolve method parameter at index ")
.append(param.getParameterIndex()).append(" in method: ") .append(param.getParameterIndex()).append(" in method: ")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 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.
@ -49,22 +49,21 @@ public class MethodArgumentNotValidException extends AbstractMethodArgumentResol
public MethodArgumentNotValidException(Message<?> message, MethodParameter parameter, public MethodArgumentNotValidException(Message<?> message, MethodParameter parameter,
BindingResult bindingResult) { BindingResult bindingResult) {
super(message, parameter, getMethodParamMessage(parameter) + super(message, parameter, getMethodParamMessage(parameter) + getValidationErrorMessage(bindingResult));
getValidationErrorMessage(parameter, bindingResult));
this.bindingResult = bindingResult; this.bindingResult = bindingResult;
} }
/** /**
* Return the BindingResult if the failure is validation-related or {@code null}. * Return the BindingResult if the failure is validation-related,
* or {@code null} if none.
*/ */
public BindingResult getBindingResult() { public final BindingResult getBindingResult() {
return this.bindingResult; return this.bindingResult;
} }
private static String getValidationErrorMessage(MethodParameter parameter, BindingResult bindingResult) { private static String getValidationErrorMessage(BindingResult bindingResult) {
if (bindingResult != null) { if (bindingResult != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(", with ").append(bindingResult.getErrorCount()).append(" error(s): "); sb.append(", with ").append(bindingResult.getErrorCount()).append(" error(s): ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 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.
@ -29,11 +29,11 @@ import org.springframework.messaging.Message;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class MethodArgumentTypeMismatchException extends AbstractMethodArgumentResolutionException { public class MethodArgumentTypeMismatchException extends AbstractMethodArgumentResolutionException {
/** /**
* Create a new instance with the invalid {@code MethodParameter}. * Create a new instance with the invalid {@code MethodParameter}.
*/ */
public MethodArgumentTypeMismatchException(Message<?> message, MethodParameter parameter, String description) { public MethodArgumentTypeMismatchException(Message<?> message, MethodParameter param, String description) {
super(message, parameter, getMethodParamMessage(parameter) + description); super(message, param, getMethodParamMessage(param) + description);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2015 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.
@ -20,8 +20,8 @@ import org.springframework.core.MethodParameter;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
/** /**
* Strategy interface for resolving method parameters into argument values in * Strategy interface for resolving method parameters into argument values
* the context of a given {@link Message}. * in the context of a given {@link Message}.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
@ -39,12 +39,12 @@ public interface HandlerMethodArgumentResolver {
/** /**
* Resolves a method parameter into an argument value from a given message. * Resolves a method parameter into an argument value from a given message.
* @param parameter the method parameter to resolve. This parameter must * @param parameter the method parameter to resolve.
* have previously been passed to * This parameter must have previously been passed to
* {@link #supportsParameter(org.springframework.core.MethodParameter)} * {@link #supportsParameter(org.springframework.core.MethodParameter)}
* and it must have returned {@code true} * which must have returned {@code true}.
* @param message the currently processed message * @param message the currently processed message
* @return the resolved argument value, or {@code null}. * @return the resolved argument value, or {@code null}
* @throws Exception in case of errors with the preparation of argument values * @throws Exception in case of errors with the preparation of argument values
*/ */
Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception; Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 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.
@ -68,7 +68,6 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
/** /**
* Configure a custom SubscriptionRegistry to use for storing subscriptions. * Configure a custom SubscriptionRegistry to use for storing subscriptions.
*
* <p><strong>Note</strong> that when a custom PathMatcher is configured via * <p><strong>Note</strong> that when a custom PathMatcher is configured via
* {@link #setPathMatcher}, if the custom registry is not an instance of * {@link #setPathMatcher}, if the custom registry is not an instance of
* {@link DefaultSubscriptionRegistry}, the provided PathMatcher is not used * {@link DefaultSubscriptionRegistry}, the provided PathMatcher is not used
@ -102,9 +101,8 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
} }
/** /**
* Configure a {@link MessageHeaderInitializer} to apply to the headers of all * Configure a {@link MessageHeaderInitializer} to apply to the headers
* messages sent to the client outbound channel. * of all messages sent to the client outbound channel.
*
* <p>By default this property is not set. * <p>By default this property is not set.
*/ */
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) { public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) {
@ -112,7 +110,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
} }
/** /**
* @return the configured header initializer. * Return the configured header initializer.
*/ */
public MessageHeaderInitializer getHeaderInitializer() { public MessageHeaderInitializer getHeaderInitializer() {
return this.headerInitializer; return this.headerInitializer;
@ -131,7 +129,6 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
@Override @Override
protected void handleMessageInternal(Message<?> message) { protected void handleMessageInternal(Message<?> message) {
MessageHeaders headers = message.getHeaders(); MessageHeaders headers = message.getHeaders();
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
String destination = SimpMessageHeaderAccessor.getDestination(headers); String destination = SimpMessageHeaderAccessor.getDestination(headers);
@ -197,7 +194,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
protected void sendMessageToSubscribers(String destination, Message<?> message) { protected void sendMessageToSubscribers(String destination, Message<?> message) {
MultiValueMap<String,String> subscriptions = this.subscriptionRegistry.findSubscriptions(message); MultiValueMap<String,String> subscriptions = this.subscriptionRegistry.findSubscriptions(message);
if ((subscriptions.size() > 0) && logger.isDebugEnabled()) { if (!subscriptions.isEmpty() && logger.isDebugEnabled()) {
logger.debug("Broadcasting to " + subscriptions.size() + " sessions."); logger.debug("Broadcasting to " + subscriptions.size() + " sessions.");
} }
for (String sessionId : subscriptions.keySet()) { for (String sessionId : subscriptions.keySet()) {

View File

@ -272,7 +272,7 @@ public class Jackson2ObjectMapperBuilder {
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class) * @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class)
*/ */
public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) { public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) {
if (mixIns != null) { if (mixinSource != null) {
this.mixIns.put(target, mixinSource); this.mixIns.put(target, mixinSource);
} }
return this; return this;

View File

@ -18,9 +18,6 @@ package org.springframework.web.servlet.mvc.method.annotation;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
@ -37,8 +34,6 @@ import org.springframework.web.method.ControllerAdviceBean;
*/ */
class ResponseBodyAdviceChain { class ResponseBodyAdviceChain {
private static final Log logger = LogFactory.getLog(ResponseBodyAdviceChain.class);
private final List<Object> advice; private final List<Object> advice;