DATAREST-416 - Switched to IdentifierAccessor API where needed.

We now use the newly introduced IdentifierAccessor API to make sure we benefit from store specific optimizations when looking up identifier values.

Added some user class lookups to make sure the projection and resource mapping lookup works if proxies types are handed around.
This commit is contained in:
Oliver Gierke
2014-11-24 13:25:43 +01:00
parent 780d674012
commit afd1027d36
4 changed files with 19 additions and 17 deletions

View File

@@ -22,6 +22,7 @@ import java.util.Map.Entry;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.data.rest.core.projection.ProjectionDefinitions;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
@@ -153,10 +154,11 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
Assert.notNull(sourceType, "Source type must not be null!");
Class<?> userType = ClassUtils.getUserClass(sourceType);
Map<String, Class<?>> result = new HashMap<String, Class<?>>();
for (Entry<ProjectionDefinitionKey, Class<?>> entry : projectionDefinitions.entrySet()) {
if (entry.getKey().sourceType.isAssignableFrom(sourceType)) {
if (entry.getKey().sourceType.isAssignableFrom(userType)) {
result.put(entry.getKey().name, entry.getValue());
}
}

View File

@@ -33,6 +33,7 @@ import org.springframework.data.rest.core.support.RepositoriesUtils;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.core.EvoInflectorRelProvider;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
@@ -89,7 +90,7 @@ public class RepositoryResourceMappings implements ResourceMappings {
public ResourceMetadata getMappingFor(Class<?> type) {
Assert.notNull(type, "Type must not be null!");
return cache.get(type);
return cache.get(ClassUtils.getUserClass(type));
}
private final void populateCache(Repositories repositories) {