removed duplicate config class
This commit is contained in:
parent
bc88cd0be7
commit
7fb6a6b508
|
@ -1,75 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.*;
|
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
|
||||||
import org.springframework.session.web.http.CookieSerializer;
|
|
||||||
import org.springframework.session.web.http.DefaultCookieSerializer;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableRedisHttpSession
|
|
||||||
@PropertySource(value = {"classpath:application.properties"} )
|
|
||||||
@ComponentScan(basePackages = {
|
|
||||||
"org.eurocris.openaire.cris.validator.service",
|
|
||||||
"eu.dnetlib.repo.manager.*"})
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
private static Logger LOGGER = Logger.getLogger(Config.class);
|
|
||||||
|
|
||||||
@Value("${redis.host}")
|
|
||||||
private String host;
|
|
||||||
|
|
||||||
@Value("${redis.port:6379}")
|
|
||||||
private String port;
|
|
||||||
|
|
||||||
@Value("${redis.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Value("${aai.mode}")
|
|
||||||
private String aai_mode;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void init(){
|
|
||||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public JedisConnectionFactory connectionFactory() {
|
|
||||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
|
||||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
|
|
||||||
jedisConnectionFactory.setHostName(host);
|
|
||||||
jedisConnectionFactory.setPort(Integer.parseInt(port));
|
|
||||||
jedisConnectionFactory.setUsePool(true);
|
|
||||||
if(password != null) jedisConnectionFactory.setPassword(password);
|
|
||||||
return jedisConnectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CookieSerializer cookieSerializer() {
|
|
||||||
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
|
||||||
serializer.setCookieName("openAIRESession");
|
|
||||||
serializer.setCookiePath("/");
|
|
||||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
|
||||||
serializer.setDomainName(".openaire.eu");
|
|
||||||
// serializer.setDomainName(".athenarc.gr");
|
|
||||||
LOGGER.info("Serializer : " + serializer);
|
|
||||||
return serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate() {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
|
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
|
||||||
httpHeaders.set("Content-Type", "application/json");
|
|
||||||
return restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue