Introduce alias for 'value' attribute in @Payload
This commit introduces 'expression' as an alias for 'value' in @Payload. Issue: SPR-11393
This commit is contained in:
parent
518c85b107
commit
250787a35a
|
@ -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.
|
||||
|
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +32,7 @@ import org.springframework.messaging.converter.MessageConverter;
|
|||
* specific MIME type to an Object matching the target method parameter.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
* @since 4.0
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
@ -39,14 +41,23 @@ import org.springframework.messaging.converter.MessageConverter;
|
|||
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.
|
||||
* Alias for {@link #expression}.
|
||||
*/
|
||||
@AliasFor(attribute="expression")
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* A SpEL expression to be evaluated against the payload object as the root context.
|
||||
* <p>
|
||||
* 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.
|
||||
*/
|
||||
@AliasFor(attribute="value")
|
||||
String expression() default "";
|
||||
|
||||
/**
|
||||
* Whether payload content is required.
|
||||
* <p>Default is {@code true}, leading to an exception if there is no payload. Switch
|
||||
|
|
|
@ -87,7 +87,7 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
|
|||
@Override
|
||||
public Object resolveArgument(MethodParameter param, Message<?> message) throws Exception {
|
||||
Payload ann = param.getParameterAnnotation(Payload.class);
|
||||
if (ann != null && StringUtils.hasText(ann.value())) {
|
||||
if (ann != null && StringUtils.hasText(ann.expression())) {
|
||||
throw new IllegalStateException("@Payload SpEL expressions not supported by this resolver");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue