Add value() attribute to @Payload
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user