diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/Payload.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/Payload.java index d83a2516b1..c268efefcb 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/Payload.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/Payload.java @@ -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. - *
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. + *
+ * 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. + *
+ * When processing STOMP over WebSocket messages this attribute is not supported. + */ + @AliasFor(attribute="value") + String expression() default ""; + /** * Whether payload content is required. *
Default is {@code true}, leading to an exception if there is no payload. Switch diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver.java index 7bb9b86515..09d1c1df7b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/PayloadArgumentResolver.java @@ -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"); }