001/*002 * Copyright 2012-2016 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * http://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.boot.autoconfigure.mobile;018019import org.thymeleaf.spring4.view.ThymeleafViewResolver;020021import org.springframework.boot.autoconfigure.AutoConfigureAfter;022import org.springframework.boot.autoconfigure.EnableAutoConfiguration;023import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;024import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;025import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;026import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;027import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;028import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration;029import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;030import org.springframework.boot.autoconfigure.mustache.web.MustacheViewResolver;031import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;032import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;033import org.springframework.boot.context.properties.EnableConfigurationProperties;034import org.springframework.context.annotation.Bean;035import org.springframework.context.annotation.Configuration;036import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver;037import org.springframework.web.servlet.view.InternalResourceViewResolver;038import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;039import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;040041/**042 * {@link EnableAutoConfiguration Auto-configuration} for Spring Mobile's043 * {@link LiteDeviceDelegatingViewResolver}. If {@link ThymeleafViewResolver} is available044 * it is configured as the delegate view resolver. Otherwise,045 * {@link InternalResourceViewResolver} is used as a fallback.046 *047 * @author Roy Clarkson048 * @author Stephane Nicoll049 * @since 1.1.0050 */051@Configuration052@ConditionalOnWebApplication053@ConditionalOnClass(LiteDeviceDelegatingViewResolver.class)054@ConditionalOnProperty(prefix = "spring.mobile.devicedelegatingviewresolver", name = "enabled", havingValue = "true")055@EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class)056@AutoConfigureAfter({ WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class,057 GroovyTemplateAutoConfiguration.class, MustacheAutoConfiguration.class,058 ThymeleafAutoConfiguration.class })059public class DeviceDelegatingViewResolverAutoConfiguration {060061 @Configuration062 protected static class LiteDeviceDelegatingViewResolverFactoryConfiguration {063064 @Bean065 public DeviceDelegatingViewResolverFactory deviceDelegatingViewResolverFactory(066