package cn.sagacloud.server.algorithm

import com.sybotan.service.interceptors.SPageInterceptor
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.context.request.async.TimeoutCallableProcessingInterceptor
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter

/**
 *
 *
 * @author jxing
 */
@Configuration
open class WebMvcConfg: WebMvcConfigurerAdapter() {

    /**
     * 设置接口超时时间
     */
//    override fun configureAsyncSupport(configurer : AsyncSupportConfigurer) {
//        configurer.setDefaultTimeout(1000 * 60 * 60)
//        configurer.registerCallableInterceptors(timeoutInterceptor())
//    }
//    @Bean
//    open fun timeoutInterceptor() : TimeoutCallableProcessingInterceptor {
//        return TimeoutCallableProcessingInterceptor()
//    }

    /**
     * 配置拦截器
     *
     * @param   registry        拦截器注册器
     */
    override fun addInterceptors(registry : InterceptorRegistry) {
        //registry.addInterceptor(AccessControlAllowOriginInterceptor()).addPathPatterns("/**")
//        registry.addInterceptor(SAccessControlAllowOriginInterceptor()).addPathPatterns("/**")
        registry.addInterceptor(SPageInterceptor()).addPathPatterns("/**")
        super.addInterceptors(registry)
    } // Function addInterceptors()
} // Class WebMvcConf()