From 4ecb3d4f3fcfe7f753b542cae6f94b4ca8fb48f1 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 25 Aug 2015 22:14:36 -0400 Subject: [PATCH] Update WebSocket docs on proxying @Controller Issue: SPR-13384 --- .../handler/annotation/MessageMapping.java | 5 +++++ .../messaging/simp/annotation/SubscribeMapping.java | 5 +++++ src/asciidoc/web-websocket.adoc | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java index 0796f8ee3b..ad0d4fca60 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMapping.java @@ -77,6 +77,11 @@ import org.springframework.messaging.Message; * have the message directed to a specific user if connected. The return value is * converted with a {@link org.springframework.messaging.converter.MessageConverter}. * + *

NOTE: When using controller interfaces (e.g. for AOP proxying), + * make sure to consistently put all your mapping annotations - such as + * {@code @MessageMapping} and {@code @SubscribeMapping} - on + * the controller interface rather than on the implementation class. + * * @author Rossen Stoyanchev * @since 4.0 * @see org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/SubscribeMapping.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/SubscribeMapping.java index 370dcc9e30..83f3d2a4b5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/SubscribeMapping.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/SubscribeMapping.java @@ -40,6 +40,11 @@ import java.lang.annotation.Target; * user and does not pass through the message broker. This is useful for * implementing a request-reply pattern. * + *

NOTE: When using controller interfaces (e.g. for AOP proxying), + * make sure to consistently put all your mapping annotations - such as + * {@code @MessageMapping} and {@code @SubscribeMapping} - on + * the controller interface rather than on the implementation class. + * * @author Rossen Stoyanchev * @since 4.0 * @see org.springframework.messaging.handler.annotation.MessageMapping diff --git a/src/asciidoc/web-websocket.adoc b/src/asciidoc/web-websocket.adoc index 87c6d32b09..2872cadd65 100644 --- a/src/asciidoc/web-websocket.adoc +++ b/src/asciidoc/web-websocket.adoc @@ -1374,6 +1374,19 @@ Or alternatively an `@SubscribeMapping` method can be annotated with `@SendTo` in which case the resulting message is sent to the `"brokerChannel"` using the specified target destination. +[NOTE] +==== +In some cases a controller may need to be decorated with an AOP proxy at runtime. +One example is if you choose to have `@Transactional` annotations directly on the +controller. When this is the case, for controllers specifically, we recommend +using class-based proxying. This is typically the default choice with controllers. +However if a controller must implement an interface that is not a Spring Context +callback (e.g. `InitializingBean`, `*Aware`, etc), you may need to explicitly +configure class-based proxying. For example with ``, +change to ``. +==== + + [[websocket-stomp-handle-send]] === Sending Messages