Subversion Repositories SmartDukaan

Rev

Rev 21236 | Rev 21277 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21236 Rev 21272
Line 1... Line 1...
1
package com.spice.profitmandi.web.config;
1
package com.spice.profitmandi.web.config;
2
 
2
 
3
import org.springframework.beans.factory.annotation.Autowired;
3
import org.springframework.beans.factory.annotation.Autowired;
-
 
4
import org.springframework.context.annotation.Bean;
4
import org.springframework.context.annotation.ComponentScan;
5
import org.springframework.context.annotation.ComponentScan;
5
import org.springframework.context.annotation.Configuration;
6
import org.springframework.context.annotation.Configuration;
6
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
8
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
8
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
9
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
Line 10... Line 11...
10
 
11
 
11
import com.spice.profitmandi.common.model.ProfitMandiConstants;
12
import com.spice.profitmandi.common.model.ProfitMandiConstants;
12
import com.spice.profitmandi.web.interceptor.ApiRequestInterceptor;
13
import com.spice.profitmandi.web.interceptor.ApiRequestInterceptor;
13
import com.spice.profitmandi.web.interceptor.RoleRequestInterceptor;
14
import com.spice.profitmandi.web.interceptor.RoleRequestInterceptor;
14
 
15
 
-
 
16
import springfox.documentation.builders.PathSelectors;
-
 
17
import springfox.documentation.builders.RequestHandlerSelectors;
-
 
18
import springfox.documentation.service.ApiInfo;
-
 
19
import springfox.documentation.spi.DocumentationType;
-
 
20
import springfox.documentation.spring.web.plugins.Docket;
-
 
21
import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
 
22
 
15
@Configuration
23
@Configuration
16
@EnableWebMvc
24
@EnableWebMvc
-
 
25
@EnableSwagger2
17
@ComponentScan("com.spice.profitmandi.*")
26
@ComponentScan("com.spice.profitmandi.*")
18
public class WebMVCConfig extends WebMvcConfigurerAdapter{
27
public class WebMVCConfig extends WebMvcConfigurerAdapter{
19
	
28
	
20
	private static final String RESOURCES_PATTERN="/resources/**";
29
	private static final String RESOURCES_PATTERN="/resources/**";
21
	private static final String RESOURCES_LOCATION="/resources/";
30
	private static final String RESOURCES_LOCATION="/resources/";
Line 24... Line 33...
24
	ApiRequestInterceptor apiRequestInterceptor;
33
	ApiRequestInterceptor apiRequestInterceptor;
25
	
34
	
26
	@Autowired
35
	@Autowired
27
	RoleRequestInterceptor roleRequestInterceptor;
36
	RoleRequestInterceptor roleRequestInterceptor;
28
	
37
	
-
 
38
	
-
 
39
	@Bean
-
 
40
	public Docket api() {
-
 
41
		return new Docket(DocumentationType.SWAGGER_2).select()
-
 
42
				.apis(RequestHandlerSelectors.any())
-
 
43
				.paths(PathSelectors.any()).build()
-
 
44
				.apiInfo(apiInfo());
-
 
45
	}
-
 
46
	
29
	@Override
47
	@Override
30
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
48
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
-
 
49
	    registry.addResourceHandler("swagger-ui.html")
-
 
50
	      .addResourceLocations("classpath:/META-INF/resources/");
-
 
51
	    registry.addResourceHandler("/webjars/**")
-
 
52
	      .addResourceLocations("classpath:/META-INF/resources/webjars/");
31
        registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
53
	    registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
32
    }
54
	}
33
	
55
	
34
	@Override
56
	@Override
35
	public void addInterceptors(InterceptorRegistry registry) {
57
	public void addInterceptors(InterceptorRegistry registry) {
36
		registry.addInterceptor(apiRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_API, ProfitMandiConstants.URL_API + "/");
58
		registry.addInterceptor(apiRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_API, ProfitMandiConstants.URL_API + "/");
37
		registry.addInterceptor(roleRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_ROLE, ProfitMandiConstants.URL_ROLE + "/");
59
		registry.addInterceptor(roleRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_ROLE, ProfitMandiConstants.URL_ROLE + "/");
38
	}
60
	}
-
 
61
	
-
 
62
	private ApiInfo apiInfo() {
-
 
63
	    @SuppressWarnings("deprecation")
-
 
64
		ApiInfo apiInfo = new ApiInfo(
-
 
65
	      "ProfitMandi API",
-
 
66
	      "Api's for profitmandi app",
-
 
67
	      "API TOS",
-
 
68
	      "Terms of service",
-
 
69
	      "New Spice Solutions Pvt. Ltd.",
-
 
70
	      "License of API",
-
 
71
	      "API license URL");
-
 
72
	    return apiInfo;
-
 
73
	}
39
}
74
}
40
75