|
19 | 19 | import java.lang.annotation.Annotation;
|
20 | 20 | import java.lang.reflect.Method;
|
21 | 21 | import java.util.Arrays;
|
22 |
| -import java.util.Collection; |
23 | 22 | import java.util.HashMap;
|
24 | 23 | import java.util.List;
|
25 | 24 | import java.util.Map;
|
26 | 25 | import java.util.Set;
|
27 | 26 | import java.util.concurrent.ConcurrentHashMap;
|
28 | 27 |
|
| 28 | +import org.apache.commons.logging.Log; |
| 29 | +import org.apache.commons.logging.LogFactory; |
29 | 30 | import org.springframework.beans.BeansException;
|
30 | 31 | import org.springframework.beans.factory.InitializingBean;
|
31 | 32 | import org.springframework.context.ApplicationContext;
|
|
34 | 35 | import org.springframework.core.annotation.AnnotationUtils;
|
35 | 36 | import org.springframework.messaging.Message;
|
36 | 37 | import org.springframework.messaging.MessageChannel;
|
| 38 | +import org.springframework.messaging.MessageHandler; |
| 39 | +import org.springframework.messaging.MessagingException; |
37 | 40 | import org.springframework.messaging.handler.annotation.MessageMapping;
|
38 | 41 | import org.springframework.messaging.handler.annotation.support.MessageBodyArgumentResolver;
|
39 | 42 | import org.springframework.messaging.handler.annotation.support.MessageExceptionHandlerMethodResolver;
|
|
60 | 63 | * @author Rossen Stoyanchev
|
61 | 64 | * @since 4.0
|
62 | 65 | */
|
63 |
| -public class AnnotationSimpMessageHandler extends AbstractSimpMessageHandler |
64 |
| - implements ApplicationContextAware, InitializingBean { |
| 66 | +public class AnnotationSimpMessageHandler implements MessageHandler, ApplicationContextAware, InitializingBean { |
| 67 | + |
| 68 | + private static final Log logger = LogFactory.getLog(AnnotationSimpMessageHandler.class); |
65 | 69 |
|
66 | 70 | private final MessageChannel outboundChannel;
|
67 | 71 |
|
@@ -104,11 +108,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
|
104 | 108 | this.applicationContext = applicationContext;
|
105 | 109 | }
|
106 | 110 |
|
107 |
| - @Override |
108 |
| - protected Collection<SimpMessageType> getSupportedMessageTypes() { |
109 |
| - return Arrays.asList(SimpMessageType.MESSAGE, SimpMessageType.SUBSCRIBE, SimpMessageType.UNSUBSCRIBE); |
110 |
| - } |
111 |
| - |
112 | 111 | @Override
|
113 | 112 | public void afterPropertiesSet() {
|
114 | 113 |
|
@@ -183,18 +182,20 @@ protected HandlerMethod createHandlerMethod(Object handler, Method method) {
|
183 | 182 | }
|
184 | 183 |
|
185 | 184 | @Override
|
186 |
| - public void handlePublish(Message<?> message) { |
187 |
| - handleMessageInternal(message, this.messageMethods); |
188 |
| - } |
| 185 | + public void handleMessage(Message<?> message) throws MessagingException { |
189 | 186 |
|
190 |
| - @Override |
191 |
| - public void handleSubscribe(Message<?> message) { |
192 |
| - handleMessageInternal(message, this.subscribeMethods); |
193 |
| - } |
| 187 | + SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message); |
| 188 | + SimpMessageType messageType = headers.getMessageType(); |
194 | 189 |
|
195 |
| - @Override |
196 |
| - public void handleUnsubscribe(Message<?> message) { |
197 |
| - handleMessageInternal(message, this.unsubscribeMethods); |
| 190 | + if (SimpMessageType.MESSAGE.equals(messageType)) { |
| 191 | + handleMessageInternal(message, this.messageMethods); |
| 192 | + } |
| 193 | + else if (SimpMessageType.SUBSCRIBE.equals(messageType)) { |
| 194 | + handleMessageInternal(message, this.subscribeMethods); |
| 195 | + } |
| 196 | + else if (SimpMessageType.UNSUBSCRIBE.equals(messageType)) { |
| 197 | + handleMessageInternal(message, this.unsubscribeMethods); |
| 198 | + } |
198 | 199 | }
|
199 | 200 |
|
200 | 201 | private void handleMessageInternal(final Message<?> message, Map<MappingInfo, HandlerMethod> handlerMethods) {
|
|
0 commit comments