001/* 002 * Copyright 2012-2018 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.hateoas; 018 019import com.fasterxml.jackson.databind.ObjectMapper; 020 021import org.springframework.boot.autoconfigure.AutoConfigureAfter; 022import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 023import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 024import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 025import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; 026import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; 027import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; 028import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; 029import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; 030import org.springframework.boot.context.properties.EnableConfigurationProperties; 031import org.springframework.context.annotation.Configuration; 032import org.springframework.context.annotation.Import; 033import org.springframework.hateoas.EntityLinks; 034import org.springframework.hateoas.LinkDiscoverers; 035import org.springframework.hateoas.Resource; 036import org.springframework.hateoas.config.EnableEntityLinks; 037import org.springframework.hateoas.config.EnableHypermediaSupport; 038import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; 039import org.springframework.plugin.core.Plugin; 040import org.springframework.web.bind.annotation.RequestMapping; 041 042/** 043 * {@link EnableAutoConfiguration Auto-configuration} for Spring HATEOAS's 044 * {@link EnableHypermediaSupport}. 045 * 046 * @author Roy Clarkson 047 * @author Oliver Gierke 048 * @author Andy Wilkinson 049 * @since 1.1.0 050 */ 051@Configuration 052@ConditionalOnClass({ Resource.class, RequestMapping.class, Plugin.class }) 053@ConditionalOnWebApplication 054@AutoConfigureAfter({ WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class, 055 HttpMessageConvertersAutoConfiguration.class, 056 RepositoryRestMvcAutoConfiguration.class }) 057@EnableConfigurationProperties(HateoasProperties.class) 058@Import(HypermediaHttpMessageConverterConfiguration.class) 059public class HypermediaAutoConfiguration { 060 061 @Configuration 062 @ConditionalOnMissingBean(LinkDiscoverers.class) 063 @ConditionalOnClass(ObjectMapper.class) 064 @EnableHypermediaSupport(type = HypermediaType.HAL) 065 protected static class HypermediaConfiguration { 066 067 } 068 069 @Configuration 070 @ConditionalOnMissingBean(EntityLinks.class) 071 @EnableEntityLinks 072 protected static class EntityLinksConfiguration { 073 074 } 075 076}