61 lines
2.0 KiB
Java
61 lines
2.0 KiB
Java
package eu.dnetlib.ariadneplus;
|
|
|
|
import freemarker.cache.ClassTemplateLoader;
|
|
import freemarker.template.TemplateExceptionHandler;
|
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
/**
|
|
* Created by Alessia Bardi on 17/10/2017.
|
|
*
|
|
* @author Alessia Bardi
|
|
*/
|
|
@Configuration
|
|
//@EnableAsync
|
|
public class AppConfig {
|
|
|
|
// @Override
|
|
// @Bean
|
|
// public Executor getAsyncExecutor() {
|
|
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
// executor.setCorePoolSize(7);
|
|
// executor.setMaxPoolSize(42);
|
|
// executor.setQueueCapacity(11);
|
|
// executor.setThreadNamePrefix("MyExecutor-");
|
|
// //executor.initialize();
|
|
// return executor;
|
|
// }
|
|
//
|
|
// @Override
|
|
// public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
|
// return new AriadnePlusAsyncUncaughtExceptionHandler();
|
|
// }
|
|
|
|
@Bean
|
|
public RestTemplate jrrRestTemplate(){
|
|
//TODO: move configuration here from CatalogueRegistrator?
|
|
return new RestTemplateBuilder().build();
|
|
}
|
|
|
|
|
|
@Bean
|
|
public freemarker.template.Configuration freemarkerConfig(){
|
|
freemarker.template.Configuration config = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_27);
|
|
ClassTemplateLoader ctl = new ClassTemplateLoader(getClass(), "/eu/dnetlib/ariadneplus/sparql");
|
|
config.setTemplateLoader(ctl);
|
|
config.setDefaultEncoding("UTF-8");
|
|
// Sets how errors will appear.
|
|
// During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
|
|
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
|
|
|
// Don't log exceptions inside FreeMarker that it will thrown at you anyway:
|
|
config.setLogTemplateExceptions(false);
|
|
|
|
// Wrap unchecked exceptions thrown during template processing into TemplateException-s.
|
|
config.setWrapUncheckedExceptions(true);
|
|
|
|
return config;
|
|
}
|
|
} |