1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.config;
|
2 |
50372
|
panagiotis
|
|
3 |
51239
|
panagiotis
|
import org.apache.log4j.Logger;
|
4 |
50372
|
panagiotis
|
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 |
51239
|
panagiotis
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
10 |
50372
|
panagiotis
|
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 |
52781
|
panagiotis
|
@PropertySource(value = {"classpath:application.properties"} )
|
19 |
54525
|
panagiotis
|
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.controllers")
|
20 |
51239
|
panagiotis
|
|
21 |
50372
|
panagiotis
|
public class Config {
|
22 |
|
|
|
23 |
51239
|
panagiotis
|
private static Logger LOGGER = Logger.getLogger(Config.class);
|
24 |
50372
|
panagiotis
|
|
25 |
51239
|
panagiotis
|
@Value("${redis.host:194.177.192.121}")
|
26 |
50372
|
panagiotis
|
private String host;
|
27 |
|
|
|
28 |
|
|
@Value("${redis.port:6379}")
|
29 |
|
|
private String port;
|
30 |
|
|
|
31 |
51330
|
panagiotis
|
@Value("${redis.password}")
|
32 |
50372
|
panagiotis
|
private String password;
|
33 |
|
|
|
34 |
53003
|
panagiotis
|
@Value("${aai.mode}")
|
35 |
|
|
private String aai_mode;
|
36 |
|
|
|
37 |
50372
|
panagiotis
|
@PostConstruct
|
38 |
|
|
private void init(){
|
39 |
|
|
LOGGER.info(host);
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
@Bean
|
43 |
51239
|
panagiotis
|
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 |
50372
|
panagiotis
|
}
|
51 |
|
|
|
52 |
|
|
@Bean
|
53 |
|
|
public CookieSerializer cookieSerializer() {
|
54 |
|
|
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
55 |
52465
|
panagiotis
|
serializer.setCookieName("openAIRESession");
|
56 |
|
|
serializer.setCookiePath("/");
|
57 |
53003
|
panagiotis
|
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
58 |
|
|
serializer.setDomainName(".openaire.eu");
|
59 |
52781
|
panagiotis
|
// serializer.setDomainName(".athenarc.gr");
|
60 |
51239
|
panagiotis
|
LOGGER.info("Serializer : " + serializer);
|
61 |
50372
|
panagiotis
|
return serializer;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
}
|