Subversion Repositories SmartDukaan

Rev

Rev 21220 | Rev 21272 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.spice.profitmandi.common.model.ProfitMandiConstants;
import com.spice.profitmandi.web.interceptor.ApiRequestInterceptor;
import com.spice.profitmandi.web.interceptor.RoleRequestInterceptor;

@Configuration
@EnableWebMvc
@ComponentScan("com.spice.profitmandi.*")
public class WebMVCConfig extends WebMvcConfigurerAdapter{
        
        private static final String RESOURCES_PATTERN="/resources/**";
        private static final String RESOURCES_LOCATION="/resources/";
        
        @Autowired
        ApiRequestInterceptor apiRequestInterceptor;
        
        @Autowired
        RoleRequestInterceptor roleRequestInterceptor;
        
        @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
    }
        
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(apiRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_API, ProfitMandiConstants.URL_API + "/");
                registry.addInterceptor(roleRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_ROLE, ProfitMandiConstants.URL_ROLE + "/");
        }
}