Add value() attribute to @Payload

This commit is contained in:
Rossen Stoyanchev
2013-10-14 22:16:13 -04:00
parent 70dfec269b
commit bcfbd862c7
3 changed files with 26 additions and 2 deletions

View File

@@ -38,6 +38,16 @@ import org.springframework.messaging.support.converter.MessageConverter;
@Documented
public @interface Payload {
/**
* A SpEL expression to be evaluated against the payload object as the root context.
* This attribute may or may not be supported depending on whether the message being
* handled contains a non-primitive Object as its payload or is in serialized form
* and requires message conversion.
* <p>
* When processing STOMP over WebSocket messages this attribute is not supported.
*/
String value() default "";
/**
* Whether payload content is required.
* <p>

View File

@@ -23,6 +23,7 @@ import org.springframework.messaging.handler.method.HandlerMethodArgumentResolve
import org.springframework.messaging.support.converter.MessageConverter;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
@@ -69,6 +70,10 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
}
}
if ((annot != null) && StringUtils.hasText(annot.value())) {
throw new IllegalStateException("@Payload SpEL expressions not supported by this resolver.");
}
return this.converter.fromMessage(message, targetClass);
}