org.springframework.messaging.support.ImmutableMessageChannelInterceptor Java Examples
The following examples show how to use
org.springframework.messaging.support.ImmutableMessageChannelInterceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StompSubProtocolHandler.java From spring-analysis-note with MIT License | 6 votes |
private boolean detectImmutableMessageInterceptor(MessageChannel channel) { if (this.immutableMessageInterceptorPresent != null) { return this.immutableMessageInterceptorPresent; } if (channel instanceof AbstractMessageChannel) { for (ChannelInterceptor interceptor : ((AbstractMessageChannel) channel).getInterceptors()) { if (interceptor instanceof ImmutableMessageChannelInterceptor) { this.immutableMessageInterceptorPresent = true; return true; } } } this.immutableMessageInterceptorPresent = false; return false; }
Example #2
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void clientInboundChannelSendMessage() throws Exception { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientInboundChannel", TestChannel.class); SubProtocolWebSocketHandler webSocketHandler = config.getBean(SubProtocolWebSocketHandler.class); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); TestWebSocketSession session = new TestWebSocketSession("s1"); session.setOpen(true); webSocketHandler.afterConnectionEstablished(session); webSocketHandler.handleMessage(session, StompTextMessageBuilder.create(StompCommand.SEND).headers("destination:/foo").build()); Message<?> message = channel.messages.get(0); StompHeaderAccessor accessor = StompHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertNotNull(accessor); assertFalse(accessor.isMutable()); assertEquals(SimpMessageType.MESSAGE, accessor.getMessageType()); assertEquals("/foo", accessor.getDestination()); }
Example #3
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void clientInboundChannelSendMessage() throws Exception { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientInboundChannel", TestChannel.class); SubProtocolWebSocketHandler webSocketHandler = config.getBean(SubProtocolWebSocketHandler.class); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); TestWebSocketSession session = new TestWebSocketSession("s1"); session.setOpen(true); webSocketHandler.afterConnectionEstablished(session); TextMessage textMessage = StompTextMessageBuilder.create(StompCommand.SEND).headers("destination:/foo").build(); webSocketHandler.handleMessage(session, textMessage); Message<?> message = channel.messages.get(0); StompHeaderAccessor accessor = StompHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertNotNull(accessor); assertFalse(accessor.isMutable()); assertEquals(SimpMessageType.MESSAGE, accessor.getMessageType()); assertEquals("/foo", accessor.getDestination()); }
Example #4
Source File: StompSubProtocolHandler.java From spring4-understanding with Apache License 2.0 | 6 votes |
private boolean detectImmutableMessageInterceptor(MessageChannel channel) { if (this.immutableMessageInterceptorPresent != null) { return this.immutableMessageInterceptorPresent; } if (channel instanceof AbstractMessageChannel) { for (ChannelInterceptor interceptor : ((AbstractMessageChannel) channel).getInterceptors()) { if (interceptor instanceof ImmutableMessageChannelInterceptor) { this.immutableMessageInterceptorPresent = true; return true; } } } this.immutableMessageInterceptorPresent = false; return false; }
Example #5
Source File: StompSubProtocolHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test // SPR-14690 public void handleMessageFromClientWithTokenAuthentication() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(new AuthenticationInterceptor("[email protected]")); channel.addInterceptor(new ImmutableMessageChannelInterceptor()); TestMessageHandler messageHandler = new TestMessageHandler(); channel.subscribe(messageHandler); StompSubProtocolHandler handler = new StompSubProtocolHandler(); handler.afterSessionStarted(this.session, channel); TextMessage wsMessage = StompTextMessageBuilder.create(StompCommand.CONNECT).build(); handler.handleMessageFromClient(this.session, wsMessage, channel); assertEquals(1, messageHandler.getMessages().size()); Message<?> message = messageHandler.getMessages().get(0); Principal user = SimpMessageHeaderAccessor.getUser(message.getHeaders()); assertNotNull(user); assertEquals("[email protected]", user.getName()); }
Example #6
Source File: StompSubProtocolHandler.java From java-technology-stack with MIT License | 6 votes |
private boolean detectImmutableMessageInterceptor(MessageChannel channel) { if (this.immutableMessageInterceptorPresent != null) { return this.immutableMessageInterceptorPresent; } if (channel instanceof AbstractMessageChannel) { for (ChannelInterceptor interceptor : ((AbstractMessageChannel) channel).getInterceptors()) { if (interceptor instanceof ImmutableMessageChannelInterceptor) { this.immutableMessageInterceptorPresent = true; return true; } } } this.immutableMessageInterceptorPresent = false; return false; }
Example #7
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void clientInboundChannelSendMessage() throws Exception { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientInboundChannel", TestChannel.class); SubProtocolWebSocketHandler webSocketHandler = config.getBean(SubProtocolWebSocketHandler.class); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); TestWebSocketSession session = new TestWebSocketSession("s1"); session.setOpen(true); webSocketHandler.afterConnectionEstablished(session); webSocketHandler.handleMessage(session, StompTextMessageBuilder.create(StompCommand.SEND).headers("destination:/foo").build()); Message<?> message = channel.messages.get(0); StompHeaderAccessor accessor = StompHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertNotNull(accessor); assertFalse(accessor.isMutable()); assertEquals(SimpMessageType.MESSAGE, accessor.getMessageType()); assertEquals("/foo", accessor.getDestination()); }
Example #8
Source File: StompSubProtocolHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test // SPR-14690 public void handleMessageFromClientWithTokenAuthentication() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(new AuthenticationInterceptor("[email protected]")); channel.addInterceptor(new ImmutableMessageChannelInterceptor()); TestMessageHandler messageHandler = new TestMessageHandler(); channel.subscribe(messageHandler); StompSubProtocolHandler handler = new StompSubProtocolHandler(); handler.afterSessionStarted(this.session, channel); TextMessage wsMessage = StompTextMessageBuilder.create(StompCommand.CONNECT).build(); handler.handleMessageFromClient(this.session, wsMessage, channel); assertEquals(1, messageHandler.getMessages().size()); Message<?> message = messageHandler.getMessages().get(0); Principal user = SimpMessageHeaderAccessor.getUser(message.getHeaders()); assertNotNull(user); assertEquals("[email protected]", user.getName()); }
Example #9
Source File: AbstractMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 5 votes |
protected final ChannelRegistration getClientOutboundChannelRegistration() { if (this.clientOutboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientOutboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientOutboundChannelRegistration = registration; } return this.clientOutboundChannelRegistration; }
Example #10
Source File: MessageBrokerBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void testChannel(String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) { AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class); for (Class<? extends MessageHandler> subscriberType : subscriberTypes) { MessageHandler subscriber = this.appContext.getBean(subscriberType); assertNotNull("No subsription for " + subscriberType, subscriber); assertTrue(channel.hasSubscription(subscriber)); } List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(interceptorCount, interceptors.size()); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); }
Example #11
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }
Example #12
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void clientOutboundChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientOutboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(1, handlers.size()); assertTrue(handlers.contains(config.getBean(SubProtocolWebSocketHandler.class))); }
Example #13
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public AbstractSubscribableChannel brokerChannel() { ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration(); ExecutorSubscribableChannel channel = reg.hasTaskExecutor() ? new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel(); reg.setInterceptors(new ImmutableMessageChannelInterceptor()); channel.setInterceptors(reg.getInterceptors()); return channel; }
Example #14
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected final ChannelRegistration getClientOutboundChannelRegistration() { if (this.clientOutboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientOutboundChannel(registration); registration.setInterceptors(new ImmutableMessageChannelInterceptor()); this.clientOutboundChannelRegistration = registration; } return this.clientOutboundChannelRegistration; }
Example #15
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected final ChannelRegistration getClientInboundChannelRegistration() { if (this.clientInboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientInboundChannel(registration); registration.setInterceptors(new ImmutableMessageChannelInterceptor()); this.clientInboundChannelRegistration = registration; } return this.clientInboundChannelRegistration; }
Example #16
Source File: MessageBrokerBeanDefinitionParserTests.java From java-technology-stack with MIT License | 5 votes |
private void testChannel( String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) { AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class); for (Class<? extends MessageHandler> subscriberType : subscriberTypes) { MessageHandler subscriber = this.appContext.getBean(subscriberType); assertNotNull("No subscription for " + subscriberType, subscriber); assertTrue(channel.hasSubscription(subscriber)); } List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(interceptorCount, interceptors.size()); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); }
Example #17
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }
Example #18
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void clientOutboundChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientOutboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(1, handlers.size()); assertTrue(handlers.contains(config.getBean(SubProtocolWebSocketHandler.class))); }
Example #19
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 5 votes |
@Bean public AbstractSubscribableChannel brokerChannel() { ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration(); ExecutorSubscribableChannel channel = (reg.hasTaskExecutor() ? new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel()); reg.interceptors(new ImmutableMessageChannelInterceptor()); channel.setLogger(SimpLogging.forLog(channel.getLogger())); channel.setInterceptors(reg.getInterceptors()); return channel; }
Example #20
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 5 votes |
protected final ChannelRegistration getClientOutboundChannelRegistration() { if (this.clientOutboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientOutboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientOutboundChannelRegistration = registration; } return this.clientOutboundChannelRegistration; }
Example #21
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 5 votes |
protected final ChannelRegistration getClientInboundChannelRegistration() { if (this.clientInboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientInboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientInboundChannelRegistration = registration; } return this.clientInboundChannelRegistration; }
Example #22
Source File: MessageBrokerBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 5 votes |
private void testChannel( String channelName, List<Class<? extends MessageHandler>> subscriberTypes, int interceptorCount) { AbstractSubscribableChannel channel = this.appContext.getBean(channelName, AbstractSubscribableChannel.class); for (Class<? extends MessageHandler> subscriberType : subscriberTypes) { MessageHandler subscriber = this.appContext.getBean(subscriberType); assertNotNull("No subscription for " + subscriberType, subscriber); assertTrue(channel.hasSubscription(subscriber)); } List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(interceptorCount, interceptors.size()); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); }
Example #23
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }
Example #24
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void clientOutboundChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("clientOutboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(1, handlers.size()); assertTrue(handlers.contains(config.getBean(SubProtocolWebSocketHandler.class))); }
Example #25
Source File: AbstractMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 5 votes |
@Bean public AbstractSubscribableChannel brokerChannel() { ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration(); ExecutorSubscribableChannel channel = (reg.hasTaskExecutor() ? new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel()); reg.interceptors(new ImmutableMessageChannelInterceptor()); channel.setLogger(SimpLogging.forLog(channel.getLogger())); channel.setInterceptors(reg.getInterceptors()); return channel; }
Example #26
Source File: AbstractMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 5 votes |
protected final ChannelRegistration getClientInboundChannelRegistration() { if (this.clientInboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientInboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientInboundChannelRegistration = registration; } return this.clientInboundChannelRegistration; }
Example #27
Source File: BinderAwareChannelResolverTests.java From spring-cloud-stream with Apache License 2.0 | 4 votes |
@Bean public GlobalChannelInterceptorWrapper testInterceptor() { return new GlobalChannelInterceptorWrapper( new ImmutableMessageChannelInterceptor()); }