001/*
002 * Copyright 2012-2017 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 at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * 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 and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.data.rest;
018
019import org.springframework.boot.autoconfigure.AutoConfigureAfter;
020import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
021import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
022import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
023import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
024import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
025import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
026import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
027import org.springframework.boot.context.properties.EnableConfigurationProperties;
028import org.springframework.context.annotation.Bean;
029import org.springframework.context.annotation.Configuration;
030import org.springframework.context.annotation.Import;
031import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
032import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
033
034/**
035 * {@link EnableAutoConfiguration Auto-configuration} for Spring Data Rest's MVC
036 * integration.
037 * <p>
038 * Activates when the application is a web application and no
039 * {@link RepositoryRestMvcConfiguration} is found.
040 * <p>
041 * Once in effect, the auto-configuration allows to configure any property of
042 * {@link RepositoryRestConfiguration} using the {@code spring.data.rest} prefix.
043 *
044 * @author Rob Winch
045 * @author Stephane Nicoll
046 * @author Andy Wilkinson
047 * @since 1.1.0
048 */
049@Configuration
050@ConditionalOnWebApplication(type = Type.SERVLET)
051@ConditionalOnMissingBean(RepositoryRestMvcConfiguration.class)
052@ConditionalOnClass(RepositoryRestMvcConfiguration.class)
053@AutoConfigureAfter({ HttpMessageConvertersAutoConfiguration.class,
054                JacksonAutoConfiguration.class })
055@EnableConfigurationProperties(RepositoryRestProperties.class)
056@Import(RepositoryRestMvcConfiguration.class)
057public class RepositoryRestMvcAutoConfiguration {
058
059        @Bean
060        public SpringBootRepositoryRestConfigurer springBootRepositoryRestConfigurer() {
061                return new SpringBootRepositoryRestConfigurer();
062        }
063
064}