DATAREST-741 - UriToEntityDeserializer now uses RepositoryInvoker directly.

UriToEntityDeserializer now uses the RepositoryInvokerFactory to resolve entity instances directly to make sure potentially registered EntityLookup instances are considered for the lookup.
This commit is contained in:
Oliver Gierke
2016-01-06 14:17:42 +01:00
parent 000f645543
commit 3ce10774d8
4 changed files with 72 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-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.
@@ -326,11 +326,12 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
factory.getEntityPathResolver());
return new QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver(repositories(),
repositoryInvokerFactory(), resourceMetadataHandlerMethodArgumentResolver(), predicateBuilder, factory);
repositoryInvokerFactory(defaultConversionService()), resourceMetadataHandlerMethodArgumentResolver(),
predicateBuilder, factory);
}
return new RootResourceInformationHandlerMethodArgumentResolver(repositories(), repositoryInvokerFactory(),
resourceMetadataHandlerMethodArgumentResolver());
return new RootResourceInformationHandlerMethodArgumentResolver(repositories(),
repositoryInvokerFactory(defaultConversionService()), resourceMetadataHandlerMethodArgumentResolver());
}
@Bean
@@ -595,12 +596,8 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
uriToEntityConverter(defaultConversionService()), selfLinkProvider());
}
/**
* @param entities
* @return
*/
protected UriToEntityConverter uriToEntityConverter(ConversionService conversionService) {
return new UriToEntityConverter(persistentEntities(), conversionService);
return new UriToEntityConverter(persistentEntities(), repositoryInvokerFactory(conversionService), repositories());
}
/**
@@ -627,10 +624,10 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
}
@Bean
public RepositoryInvokerFactory repositoryInvokerFactory() {
public RepositoryInvokerFactory repositoryInvokerFactory(@Qualifier ConversionService defaultConversionService) {
return new UnwrappingRepositoryInvokerFactory(
new DefaultRepositoryInvokerFactory(repositories(), defaultConversionService()), getEntityLookups());
new DefaultRepositoryInvokerFactory(repositories(), defaultConversionService), getEntityLookups());
}
@Bean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-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.
@@ -28,6 +28,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.context.PersistentEntities;
import org.springframework.data.repository.support.DefaultRepositoryInvokerFactory;
import org.springframework.data.repository.support.DomainClassConverter;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.rest.core.UriToEntityConverter;
@@ -62,7 +63,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Jon Brisbin
* @author Greg Trunquist
* @author Greg Turnquist
* @author Oliver Gierke
*/
@Configuration
@@ -119,8 +120,8 @@ public class RepositoryTestsConfig {
SelfLinkProvider selfLinkProvider = new DefaultSelfLinkProvider(persistentEntities(), entityLinks,
Collections.<EntityLookup<?>> emptyList());
return new PersistentEntityJackson2Module(mappings, persistentEntities(), config(),
new UriToEntityConverter(persistentEntities(), defaultConversionService()), selfLinkProvider);
return new PersistentEntityJackson2Module(mappings, persistentEntities(), config(), new UriToEntityConverter(
persistentEntities(), new DefaultRepositoryInvokerFactory(repositories()), repositories()), selfLinkProvider);
}
@Bean