Rework RedisHttpSessionConfiguration to bean method invocations

Closes: #1362
This commit is contained in:
Vedran Pavic
2019-03-14 19:56:51 +01:00
parent 408f2da108
commit 8b40e8cce8

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2014-2018 the original author or authors. * Copyright 2014-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -125,7 +125,8 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio
} }
@Bean @Bean
public RedisMessageListenerContainer redisMessageListenerContainer() { public RedisMessageListenerContainer redisMessageListenerContainer(
RedisOperationsSessionRepository sessionRepository) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer(); RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(this.redisConnectionFactory); container.setConnectionFactory(this.redisConnectionFactory);
if (this.redisTaskExecutor != null) { if (this.redisTaskExecutor != null) {
@@ -134,12 +135,13 @@ public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguratio
if (this.redisSubscriptionExecutor != null) { if (this.redisSubscriptionExecutor != null) {
container.setSubscriptionExecutor(this.redisSubscriptionExecutor); container.setSubscriptionExecutor(this.redisSubscriptionExecutor);
} }
container.addMessageListener(sessionRepository(), Arrays.asList( container.addMessageListener(sessionRepository,
new ChannelTopic(sessionRepository().getSessionDeletedChannel()), Arrays.asList(
new ChannelTopic(sessionRepository().getSessionExpiredChannel()))); new ChannelTopic(sessionRepository.getSessionDeletedChannel()),
container.addMessageListener(sessionRepository(), new ChannelTopic(sessionRepository.getSessionExpiredChannel())));
container.addMessageListener(sessionRepository,
Collections.singletonList(new PatternTopic( Collections.singletonList(new PatternTopic(
sessionRepository().getSessionCreatedChannelPrefix() + "*"))); sessionRepository.getSessionCreatedChannelPrefix() + "*")));
return container; return container;
} }