From 4ebc1be2be327493219f1d89ff600c8f3d30e5be Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Sun, 24 Jul 2016 18:58:41 +0200 Subject: [PATCH] #469 - Removed support for AnnotationMethodHandlerAdapter. Added a Spring 5 specific build profile and removed the references to AnnotationMethodHandlerAdapter which already had been deprecated in the latest Spring 3 in favor of RequestMappingHandlerAdapter. Updated Spring build profiles in general. --- .travis.yml | 4 ++- pom.xml | 30 ++++++++++++++++--- ...ermediaSupportBeanDefinitionRegistrar.java | 13 +++----- ...nableHypermediaSupportIntegrationTest.java | 20 ++----------- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3efdaba6..6faf766e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,10 @@ env: matrix: - PROFILE=non-existant - PROFILE=spring42 - - PROFILE=spring43 - PROFILE=spring42-next + - PROFILE=spring43 + - PROFILE=spring43-next + - PROFILE=spring5-next cache: directories: - $HOME/.m2 diff --git a/pom.xml b/pom.xml index 662f1583b..94d5331e2 100644 --- a/pom.xml +++ b/pom.xml @@ -81,10 +81,10 @@ - spring43 + spring42-next - 4.3.0.RC1 - 2.7.4 + 4.2.7.BUILD-SNAPSHOT + 2.6.5 @@ -94,10 +94,32 @@ + + spring43 + + 4.3.1.RELEASE + 2.7.4 + + + spring43-next - 4.3.0.BUILD-SNAPSHOT + 4.3.2.BUILD-SNAPSHOT + 2.7.4 + + + + spring-libs-snapshot + http://repo.spring.io/libs-snapshot + + + + + + spring5-next + + 5.0.0.BUILD-SNAPSHOT 2.7.4 diff --git a/src/main/java/org/springframework/hateoas/config/HypermediaSupportBeanDefinitionRegistrar.java b/src/main/java/org/springframework/hateoas/config/HypermediaSupportBeanDefinitionRegistrar.java index 913f55c1e..c1bf6e44f 100644 --- a/src/main/java/org/springframework/hateoas/config/HypermediaSupportBeanDefinitionRegistrar.java +++ b/src/main/java/org/springframework/hateoas/config/HypermediaSupportBeanDefinitionRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2016 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. @@ -64,7 +64,6 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.web.client.RestTemplate; -import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -77,7 +76,6 @@ * * @author Oliver Gierke */ -@SuppressWarnings("deprecation") class HypermediaSupportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar { private static final String DELEGATING_REL_PROVIDER_BEAN_NAME = "_relProvider"; @@ -253,13 +251,10 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro adapter.setMessageConverters(potentiallyRegisterModule(adapter.getMessageConverters())); } - if (bean instanceof AnnotationMethodHandlerAdapter) { + if (bean instanceof RequestMappingHandlerAdapter) { - AnnotationMethodHandlerAdapter adapter = (AnnotationMethodHandlerAdapter) bean; - List> augmentedConverters = potentiallyRegisterModule( - Arrays.asList(adapter.getMessageConverters())); - adapter - .setMessageConverters(augmentedConverters.toArray(new HttpMessageConverter[augmentedConverters.size()])); + RequestMappingHandlerAdapter adapter = (RequestMappingHandlerAdapter) bean; + adapter.setMessageConverters(potentiallyRegisterModule(adapter.getMessageConverters())); } if (bean instanceof RestTemplate) { diff --git a/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java b/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java index f5101e369..4ac60d3aa 100644 --- a/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java @@ -19,7 +19,6 @@ import static org.junit.Assert.*; import java.lang.reflect.Method; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -50,7 +49,6 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; -import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter; import org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; @@ -62,7 +60,6 @@ * * @author Oliver Gierke */ -@SuppressWarnings("deprecation") @RunWith(MockitoJUnitRunner.class) public class EnableHypermediaSupportIntegrationTest { @@ -152,13 +149,13 @@ public void configuresDefaultObjectMapperForHalToIgnoreUnknownProperties() { private static void assertEntityLinksSetUp(ApplicationContext context) { Map discoverers = context.getBeansOfType(EntityLinks.class); - assertThat(discoverers.values(), Matchers. hasItem(instanceOf(DelegatingEntityLinks.class))); + assertThat(discoverers.values(), Matchers.hasItem(instanceOf(DelegatingEntityLinks.class))); } private static void assertRelProvidersSetUp(ApplicationContext context) { Map discoverers = context.getBeansOfType(RelProvider.class); - assertThat(discoverers.values(), Matchers. hasItem(instanceOf(DelegatingRelProvider.class))); + assertThat(discoverers.values(), Matchers.hasItem(instanceOf(DelegatingRelProvider.class))); } @SuppressWarnings({ "unchecked" }) @@ -171,11 +168,7 @@ private static void assertHalSetupForConfigClass(Class configClass) { RequestMappingHandlerAdapter rmha = context.getBean(RequestMappingHandlerAdapter.class); assertThat(rmha.getMessageConverters(), - Matchers.> hasItems(instanceOf(MappingJackson2HttpMessageConverter.class))); - - AnnotationMethodHandlerAdapter amha = context.getBean(AnnotationMethodHandlerAdapter.class); - assertThat(Arrays.asList(amha.getMessageConverters()), - Matchers.> hasItems(instanceOf(MappingJackson2HttpMessageConverter.class))); + Matchers.>hasItems(instanceOf(MappingJackson2HttpMessageConverter.class))); } /** @@ -215,13 +208,6 @@ public RequestMappingHandlerAdapter rmh() { return adapter; } - @Bean - public AnnotationMethodHandlerAdapter amha() { - AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter(); - numberOfMessageConvertersLegacy = adapter.getMessageConverters().length; - return adapter; - } - @Bean public RestTemplate restTemplate() { return new RestTemplate();