1
|
/*
|
2
|
package eu.dnetlib.repo.manager.server.config;
|
3
|
|
4
|
import org.apache.log4j.Logger;
|
5
|
import org.springframework.beans.factory.annotation.Value;
|
6
|
import org.springframework.context.annotation.Bean;
|
7
|
import org.springframework.context.annotation.Configuration;
|
8
|
import org.springframework.context.annotation.PropertySource;
|
9
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
10
|
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
11
|
import org.springframework.session.web.http.CookieSerializer;
|
12
|
import org.springframework.session.web.http.DefaultCookieSerializer;
|
13
|
|
14
|
import javax.annotation.PostConstruct;
|
15
|
|
16
|
@Configuration
|
17
|
@EnableRedisHttpSession
|
18
|
@PropertySource(value = { "classpath:eu/dnetlib/repo/manager/server/springContext-repo-manager.properties"} )
|
19
|
public class Config {
|
20
|
|
21
|
private static Logger LOGGER = Logger.getLogger(Config.class);
|
22
|
|
23
|
@Value("${rediss.host:localhost}")
|
24
|
private String host;
|
25
|
|
26
|
@Value("${rediss.port:6379}")
|
27
|
private String port;
|
28
|
|
29
|
@Value("${rediss.password:#{null}}")
|
30
|
private String password;
|
31
|
|
32
|
@PostConstruct
|
33
|
private void init(){
|
34
|
LOGGER.info(host);
|
35
|
}
|
36
|
|
37
|
@Bean
|
38
|
JedisConnectionFactory connectionFactory() {
|
39
|
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
40
|
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
41
|
jedisConnectionFactory.setHostName(host);
|
42
|
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
43
|
if(password != null) jedisConnectionFactory.setPassword(password);
|
44
|
return jedisConnectionFactory;
|
45
|
}
|
46
|
|
47
|
@Bean
|
48
|
public CookieSerializer cookieSerializer() {
|
49
|
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
50
|
serializer.setCookieName("SESSION"); // <1>
|
51
|
serializer.setCookiePath("/"); // <2>
|
52
|
return serializer;
|
53
|
}
|
54
|
|
55
|
}
|
56
|
*/
|