|
@@ -4,6 +4,7 @@ import org.hsweb.web.core.session.HttpSessionManager;
|
|
import org.hsweb.web.core.session.HttpSessionManagerListener;
|
|
import org.hsweb.web.core.session.HttpSessionManagerListener;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.core.Ordered;
|
|
@@ -14,25 +15,17 @@ import org.springframework.session.data.redis.RedisOperationsSessionRepository;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
-/**
|
|
|
|
- * Created by zhouhao on 16-5-27.
|
|
|
|
- */
|
|
|
|
@Configuration
|
|
@Configuration
|
|
@ConditionalOnBean(value = RedisOperationsSessionRepository.class, name = "sessionRedisTemplate")
|
|
@ConditionalOnBean(value = RedisOperationsSessionRepository.class, name = "sessionRedisTemplate")
|
|
-@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
|
|
|
|
+@ConditionalOnWebApplication
|
|
public class RedisHttpSessionManagerConfiguration {
|
|
public class RedisHttpSessionManagerConfiguration {
|
|
- @Autowired(required = false)
|
|
|
|
- private List<HttpSessionManagerListener> httpSessionManagerListeners;
|
|
|
|
|
|
|
|
@Resource(name = "sessionRedisTemplate")
|
|
@Resource(name = "sessionRedisTemplate")
|
|
private RedisTemplate sessionRedisTemplate;
|
|
private RedisTemplate sessionRedisTemplate;
|
|
|
|
|
|
- @Bean
|
|
|
|
- public HttpSessionManager sessionListener(RedisOperationsSessionRepository repository) {
|
|
|
|
|
|
+ @Bean(name = "httpSessionManager")
|
|
|
|
+ public HttpSessionManager redisHttpSessionManager(RedisOperationsSessionRepository repository) {
|
|
RedisHttpSessionManager redisHttpSessionManager = new RedisHttpSessionManager();
|
|
RedisHttpSessionManager redisHttpSessionManager = new RedisHttpSessionManager();
|
|
- if (httpSessionManagerListeners != null) {
|
|
|
|
- redisHttpSessionManager.setListeners(httpSessionManagerListeners);
|
|
|
|
- }
|
|
|
|
redisHttpSessionManager.setSessionRedisTemplate(sessionRedisTemplate);
|
|
redisHttpSessionManager.setSessionRedisTemplate(sessionRedisTemplate);
|
|
redisHttpSessionManager.setRedisOperationsSessionRepository(repository);
|
|
redisHttpSessionManager.setRedisOperationsSessionRepository(repository);
|
|
return redisHttpSessionManager;
|
|
return redisHttpSessionManager;
|