1
|
package eu.dnetlib.parthenos;
|
2
|
|
3
|
import freemarker.cache.ClassTemplateLoader;
|
4
|
import freemarker.template.TemplateExceptionHandler;
|
5
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
6
|
import org.springframework.context.annotation.Bean;
|
7
|
import org.springframework.context.annotation.Configuration;
|
8
|
import org.springframework.web.client.RestTemplate;
|
9
|
|
10
|
/**
|
11
|
* Created by Alessia Bardi on 17/10/2017.
|
12
|
*
|
13
|
* @author Alessia Bardi
|
14
|
*/
|
15
|
@Configuration
|
16
|
//@EnableAsync
|
17
|
public class AppConfig {
|
18
|
|
19
|
// @Override
|
20
|
// @Bean
|
21
|
// public Executor getAsyncExecutor() {
|
22
|
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
23
|
// executor.setCorePoolSize(7);
|
24
|
// executor.setMaxPoolSize(42);
|
25
|
// executor.setQueueCapacity(11);
|
26
|
// executor.setThreadNamePrefix("MyExecutor-");
|
27
|
// //executor.initialize();
|
28
|
// return executor;
|
29
|
// }
|
30
|
//
|
31
|
// @Override
|
32
|
// public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
33
|
// return new ParthenosAsyncUncaughtExceptionHandler();
|
34
|
// }
|
35
|
|
36
|
@Bean
|
37
|
public RestTemplate jrrRestTemplate(){
|
38
|
//TODO: move configuration here from CatalogueRegistrator?
|
39
|
return new RestTemplateBuilder().build();
|
40
|
}
|
41
|
|
42
|
|
43
|
@Bean
|
44
|
public freemarker.template.Configuration freemarkerConfig(){
|
45
|
freemarker.template.Configuration config = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_27);
|
46
|
ClassTemplateLoader ctl = new ClassTemplateLoader(getClass(), "/eu/dnetlib/parthenos/sparql");
|
47
|
config.setTemplateLoader(ctl);
|
48
|
config.setDefaultEncoding("UTF-8");
|
49
|
// Sets how errors will appear.
|
50
|
// During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
|
51
|
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
52
|
|
53
|
// Don't log exceptions inside FreeMarker that it will thrown at you anyway:
|
54
|
config.setLogTemplateExceptions(false);
|
55
|
|
56
|
// Wrap unchecked exceptions thrown during template processing into TemplateException-s.
|
57
|
config.setWrapUncheckedExceptions(true);
|
58
|
|
59
|
return config;
|
60
|
}
|
61
|
}
|