Skip to content

Commit

Permalink
#469 - Removed support for AnnotationMethodHandlerAdapter.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odrotbohm committed Jul 25, 2016
1 parent bdb441c commit 4ebc1be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 26 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
</profile>

<profile>
<id>spring43</id>
<id>spring42-next</id>
<properties>
<spring.version>4.3.0.RC1</spring.version>
<jackson.version>2.7.4</jackson.version>
<spring.version>4.2.7.BUILD-SNAPSHOT</spring.version>
<jackson.version>2.6.5</jackson.version>
</properties>
<repositories>
<repository>
Expand All @@ -94,10 +94,32 @@
</repositories>
</profile>

<profile>
<id>spring43</id>
<properties>
<spring.version>4.3.1.RELEASE</spring.version>
<jackson.version>2.7.4</jackson.version>
</properties>
</profile>

<profile>
<id>spring43-next</id>
<properties>
<spring.version>4.3.0.BUILD-SNAPSHOT</spring.version>
<spring.version>4.3.2.BUILD-SNAPSHOT</spring.version>
<jackson.version>2.7.4</jackson.version>
</properties>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>
</profile>

<profile>
<id>spring5-next</id>
<properties>
<spring.version>5.0.0.BUILD-SNAPSHOT</spring.version>
<jackson.version>2.7.4</jackson.version>
</properties>
<repositories>
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -77,7 +76,6 @@
*
* @author Oliver Gierke
*/
@SuppressWarnings("deprecation")
class HypermediaSupportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

private static final String DELEGATING_REL_PROVIDER_BEAN_NAME = "_relProvider";
Expand Down Expand Up @@ -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<HttpMessageConverter<?>> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -62,7 +60,6 @@
*
* @author Oliver Gierke
*/
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
public class EnableHypermediaSupportIntegrationTest {

Expand Down Expand Up @@ -152,13 +149,13 @@ public void configuresDefaultObjectMapperForHalToIgnoreUnknownProperties() {
private static void assertEntityLinksSetUp(ApplicationContext context) {

Map<String, EntityLinks> discoverers = context.getBeansOfType(EntityLinks.class);
assertThat(discoverers.values(), Matchers.<EntityLinks> hasItem(instanceOf(DelegatingEntityLinks.class)));
assertThat(discoverers.values(), Matchers.<EntityLinks>hasItem(instanceOf(DelegatingEntityLinks.class)));
}

private static void assertRelProvidersSetUp(ApplicationContext context) {

Map<String, RelProvider> discoverers = context.getBeansOfType(RelProvider.class);
assertThat(discoverers.values(), Matchers.<RelProvider> hasItem(instanceOf(DelegatingRelProvider.class)));
assertThat(discoverers.values(), Matchers.<RelProvider>hasItem(instanceOf(DelegatingRelProvider.class)));
}

@SuppressWarnings({ "unchecked" })
Expand All @@ -171,11 +168,7 @@ private static void assertHalSetupForConfigClass(Class<?> configClass) {

RequestMappingHandlerAdapter rmha = context.getBean(RequestMappingHandlerAdapter.class);
assertThat(rmha.getMessageConverters(),
Matchers.<HttpMessageConverter<?>> hasItems(instanceOf(MappingJackson2HttpMessageConverter.class)));

AnnotationMethodHandlerAdapter amha = context.getBean(AnnotationMethodHandlerAdapter.class);
assertThat(Arrays.asList(amha.getMessageConverters()),
Matchers.<HttpMessageConverter<?>> hasItems(instanceOf(MappingJackson2HttpMessageConverter.class)));
Matchers.<HttpMessageConverter<?>>hasItems(instanceOf(MappingJackson2HttpMessageConverter.class)));
}

/**
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4ebc1be

Please sign in to comment.