@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 201 4 the original author or authors .
* Copyright 2012 - 201 6 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.mobile;
import java.util.List ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.boot.autoconfigure.AutoConfigureAfter ;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass ;
@ -48,25 +47,33 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
SitePreferenceHandlerMethodArgumentResolver . class } )
@AutoConfigureAfter ( DeviceResolverAutoConfiguration . class )
@ConditionalOnProperty ( prefix = "spring.mobile.sitepreference" , name = "enabled" , havingValue = "true" , matchIfMissing = true )
@ConditionalOnWebApplication
public class SitePreferenceAutoConfiguration {
@Bean
@ConditionalOnMissingBean ( SitePreferenceHandlerInterceptor . class )
public SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor ( ) {
return new SitePreferenceHandlerInterceptor ( ) ;
}
@Bean
public SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver ( ) {
return new SitePreferenceHandlerMethodArgumentResolver ( ) ;
}
@Configuration
@ConditionalOnWebApplication
protected static class SitePreferenceMvcConfiguration
extends WebMvcConfigurerAdapter {
@Autowired
private SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor ;
private final SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor ;
@Bean
@ConditionalOnMissingBean ( SitePreferenceHandlerInterceptor . class )
public SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor ( ) {
return new SitePreferenceHandlerInterceptor ( ) ;
}
private final SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver ;
@Bean
public SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver ( ) {
return new SitePreferenceHandlerMethodArgumentResolver ( ) ;
protected SitePreferenceMvcConfiguration (
SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor ,
org . springframework . mobile . device . site . SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver ) {
this . sitePreferenceHandlerInterceptor = sitePreferenceHandlerInterceptor ;
this . sitePreferenceHandlerMethodArgumentResolver = sitePreferenceHandlerMethodArgumentResolver ;
}
@Override
@ -77,7 +84,7 @@ public class SitePreferenceAutoConfiguration {
@Override
public void addArgumentResolvers (
List < HandlerMethodArgumentResolver > argumentResolvers ) {
argumentResolvers . add ( sitePreferenceHandlerMethodArgumentResolver ( ) ) ;
argumentResolvers . add ( this . sitePreferenceHandlerMethodArgumentResolver ) ;
}
}