Polishing

(cherry picked from commit ca9a078)
This commit is contained in:
Juergen Hoeller
2015-12-10 00:31:37 +01:00
parent 4b27a6ddee
commit 1d0c2f6f0e
4 changed files with 14 additions and 15 deletions

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");
* you may not use this file except in compliance with the License.
@@ -162,7 +162,7 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio
}
List<String> matches = new ArrayList<String>();
for (String pattern : patterns) {
for (String pattern : this.patterns) {
if (pattern.equals(destination) || this.pathMatcher.match(pattern, destination)) {
matches.add(pattern);
}

View File

@@ -85,8 +85,8 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
}
@Override
public Object resolveArgument(MethodParameter param, Message<?> message) throws Exception {
Payload ann = param.getParameterAnnotation(Payload.class);
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception {
Payload ann = parameter.getParameterAnnotation(Payload.class);
if (ann != null && StringUtils.hasText(ann.value())) {
throw new IllegalStateException("@Payload SpEL expressions not supported by this resolver");
}
@@ -94,19 +94,19 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
Object payload = message.getPayload();
if (isEmptyPayload(payload)) {
if (ann == null || ann.required()) {
String paramName = getParameterName(param);
String paramName = getParameterName(parameter);
BindingResult bindingResult = new BeanPropertyBindingResult(payload, paramName);
bindingResult.addError(new ObjectError(paramName, "@Payload param is required"));
throw new MethodArgumentNotValidException(message, param, bindingResult);
bindingResult.addError(new ObjectError(paramName, "Payload value must not be empty"));
throw new MethodArgumentNotValidException(message, parameter, bindingResult);
}
else {
return null;
}
}
Class<?> targetClass = param.getParameterType();
Class<?> targetClass = parameter.getParameterType();
if (ClassUtils.isAssignable(targetClass, payload.getClass())) {
validate(message, param, payload);
validate(message, parameter, payload);
return payload;
}
else {
@@ -115,7 +115,7 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
throw new MessageConversionException(message,
"No converter found to convert to " + targetClass + ", message=" + message);
}
validate(message, param, payload);
validate(message, parameter, payload);
return payload;
}
}

View File

@@ -413,7 +413,7 @@ public abstract class AbstractMethodMessageHandler<T>
for (T mapping : mappingsToCheck) {
T match = getMatchingMapping(mapping, message);
if (match != null) {
matches.add(new Match(match, handlerMethods.get(mapping)));
matches.add(new Match(match, this.handlerMethods.get(mapping)));
}
}
}

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");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class SimpMessageTypeMessageCondition extends AbstractMessageCondition<Si
@Override
protected Collection<?> getContent() {
return Arrays.asList(messageType);
return Arrays.asList(this.messageType);
}
@Override
@@ -72,12 +72,10 @@ public class SimpMessageTypeMessageCondition extends AbstractMessageCondition<Si
@Override
public SimpMessageTypeMessageCondition getMatchingCondition(Message<?> message) {
Object actualMessageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders());
if (actualMessageType == null) {
return null;
}
return this;
}
@@ -97,4 +95,5 @@ public class SimpMessageTypeMessageCondition extends AbstractMessageCondition<Si
}
return 0;
}
}