1
|
package eu.dnetlib.repo.manager.service.config;
|
2
|
|
3
|
import org.apache.log4j.Logger;
|
4
|
import org.springframework.beans.factory.annotation.Value;
|
5
|
import org.springframework.context.annotation.Bean;
|
6
|
import org.springframework.context.annotation.ComponentScan;
|
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:application.properties"} )
|
19
|
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.service.controllers")
|
20
|
|
21
|
public class Config {
|
22
|
|
23
|
private static Logger LOGGER = Logger.getLogger(Config.class);
|
24
|
|
25
|
@Value("${redis.host:194.177.192.121}")
|
26
|
private String host;
|
27
|
|
28
|
@Value("${redis.port:6379}")
|
29
|
private String port;
|
30
|
|
31
|
@Value("${redis.password}")
|
32
|
private String password;
|
33
|
|
34
|
@Value("${aai.mode}")
|
35
|
private String aai_mode;
|
36
|
|
37
|
@PostConstruct
|
38
|
private void init(){
|
39
|
LOGGER.info(host);
|
40
|
}
|
41
|
|
42
|
@Bean
|
43
|
JedisConnectionFactory connectionFactory() {
|
44
|
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
45
|
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
46
|
jedisConnectionFactory.setHostName(host);
|
47
|
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
48
|
if(password != null) jedisConnectionFactory.setPassword(password);
|
49
|
return jedisConnectionFactory;
|
50
|
}
|
51
|
|
52
|
@Bean
|
53
|
public CookieSerializer cookieSerializer() {
|
54
|
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
55
|
serializer.setCookieName("openAIRESession");
|
56
|
serializer.setCookiePath("/");
|
57
|
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
58
|
serializer.setDomainName(".openaire.eu");
|
59
|
// serializer.setDomainName(".athenarc.gr");
|
60
|
LOGGER.info("Serializer : " + serializer);
|
61
|
return serializer;
|
62
|
}
|
63
|
|
64
|
}
|