DATAREST-1341 - Move off of Java8PluginRegistry in favor of Spring Plugin's update one.

This commit is contained in:
Oliver Drotbohm
2019-02-07 20:33:44 +01:00
parent af6f55a92c
commit 93b8e68bbf
10 changed files with 29 additions and 64 deletions

View File

@@ -18,9 +18,9 @@ package org.springframework.data.rest.core.support;
import java.util.List;
import org.springframework.data.mapping.context.PersistentEntities;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.Link;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
/**
@@ -35,7 +35,7 @@ public class DefaultSelfLinkProvider implements SelfLinkProvider {
private final PersistentEntities entities;
private final EntityLinks entityLinks;
private final Java8PluginRegistry<EntityLookup<?>, Class<?>> lookups;
private final PluginRegistry<EntityLookup<?>, Class<?>> lookups;
/**
* Creates a new {@link DefaultSelfLinkProvider} from the {@link PersistentEntities}, {@link EntityLinks} and
@@ -54,7 +54,7 @@ public class DefaultSelfLinkProvider implements SelfLinkProvider {
this.entities = entities;
this.entityLinks = entityLinks;
this.lookups = Java8PluginRegistry.of(lookups);
this.lookups = PluginRegistry.of(lookups);
}
/*

View File

@@ -28,7 +28,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.support.RepositoryInvoker;
import org.springframework.data.repository.support.RepositoryInvokerFactory;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
@@ -41,7 +41,7 @@ import org.springframework.util.MultiValueMap;
public class UnwrappingRepositoryInvokerFactory implements RepositoryInvokerFactory {
private final RepositoryInvokerFactory delegate;
private final Java8PluginRegistry<EntityLookup<?>, Class<?>> lookups;
private final PluginRegistry<EntityLookup<?>, Class<?>> lookups;
/**
* @param delegate must not be {@literal null}.
@@ -54,7 +54,7 @@ public class UnwrappingRepositoryInvokerFactory implements RepositoryInvokerFact
Assert.notNull(lookups, "EntityLookups must not be null!");
this.delegate = delegate;
this.lookups = Java8PluginRegistry.of(lookups);
this.lookups = PluginRegistry.of(lookups);
}
/*

View File

@@ -21,20 +21,21 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.Plugin;
import org.springframework.plugin.core.PluginRegistry;
/**
* @author Oliver Gierke
* @deprecated since 3.2, for removal 3.3.
*/
@Deprecated
@RequiredArgsConstructor
public class Java8PluginRegistry<T extends Plugin<S>, S> {
private final PluginRegistry<T, S> registry;
public static <T extends Plugin<S>, S> Java8PluginRegistry<T, S> of(List<? extends T> plugins) {
return Java8PluginRegistry.of(OrderAwarePluginRegistry.create(plugins));
return Java8PluginRegistry.of(PluginRegistry.of(plugins));
}
public static <T extends Plugin<S>, S> Java8PluginRegistry<T, S> of(PluginRegistry<T, S> plugins) {

View File

@@ -17,7 +17,6 @@ package org.springframework.data.rest.tests;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -39,7 +38,6 @@ import org.springframework.data.rest.core.mapping.RepositoryResourceMappings;
import org.springframework.data.rest.core.support.DefaultSelfLinkProvider;
import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.SelfLinkProvider;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.EmbeddedResourcesAssembler;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.LookupObjectSerializer;
@@ -57,6 +55,7 @@ import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.core.EvoInflectorRelProvider;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.hateoas.mvc.ResourceProcessorInvoker;
import org.springframework.plugin.core.PluginRegistry;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -109,8 +108,7 @@ public class RepositoryTestsConfig {
RepositoryResourceMappings mappings = new RepositoryResourceMappings(repositories(), persistentEntities(),
config());
EntityLinks entityLinks = new RepositoryEntityLinks(repositories(), mappings, config(),
mock(PagingAndSortingTemplateVariables.class),
Java8PluginRegistry.of(Arrays.asList(DefaultIdConverter.INSTANCE)));
mock(PagingAndSortingTemplateVariables.class), PluginRegistry.of(DefaultIdConverter.INSTANCE));
SelfLinkProvider selfLinkProvider = new DefaultSelfLinkProvider(persistentEntities(), entityLinks,
Collections.<EntityLookup<?>> emptyList());

View File

@@ -17,7 +17,6 @@ package org.springframework.data.rest.webmvc.json;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -39,7 +38,6 @@ import org.springframework.data.rest.core.mapping.RepositoryResourceMappings;
import org.springframework.data.rest.core.support.DefaultSelfLinkProvider;
import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.SelfLinkProvider;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.EmbeddedResourcesAssembler;
import org.springframework.data.rest.webmvc.jpa.Person;
import org.springframework.data.rest.webmvc.jpa.PersonRepository;
@@ -58,6 +56,7 @@ import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.core.EvoInflectorRelProvider;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.hateoas.mvc.ResourceProcessorInvoker;
import org.springframework.plugin.core.PluginRegistry;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -117,8 +116,7 @@ public class RepositoryTestsConfig {
RepositoryResourceMappings mappings = new RepositoryResourceMappings(repositories(), persistentEntities(),
config());
EntityLinks entityLinks = new RepositoryEntityLinks(repositories(), mappings, config(),
mock(PagingAndSortingTemplateVariables.class),
Java8PluginRegistry.of(Arrays.asList(DefaultIdConverter.INSTANCE)));
mock(PagingAndSortingTemplateVariables.class), PluginRegistry.of(DefaultIdConverter.INSTANCE));
SelfLinkProvider selfLinkProvider = new DefaultSelfLinkProvider(persistentEntities(), entityLinks,
Collections.<EntityLookup<?>> emptyList());

View File

@@ -75,48 +75,18 @@ import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.RepositoryRelProvider;
import org.springframework.data.rest.core.support.SelfLinkProvider;
import org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.BasePathAwareController;
import org.springframework.data.rest.webmvc.BasePathAwareHandlerMapping;
import org.springframework.data.rest.webmvc.BaseUri;
import org.springframework.data.rest.webmvc.EmbeddedResourcesAssembler;
import org.springframework.data.rest.webmvc.HttpHeadersPreparer;
import org.springframework.data.rest.webmvc.ProfileResourceProcessor;
import org.springframework.data.rest.webmvc.RepositoryRestController;
import org.springframework.data.rest.webmvc.RepositoryRestExceptionHandler;
import org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter;
import org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping;
import org.springframework.data.rest.webmvc.RestMediaTypes;
import org.springframework.data.rest.webmvc.ServerHttpRequestMethodArgumentResolver;
import org.springframework.data.rest.webmvc.*;
import org.springframework.data.rest.webmvc.alps.AlpsJsonHttpMessageConverter;
import org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter;
import org.springframework.data.rest.webmvc.convert.UriListHttpMessageConverter;
import org.springframework.data.rest.webmvc.json.DomainObjectReader;
import org.springframework.data.rest.webmvc.json.EnumTranslator;
import org.springframework.data.rest.webmvc.json.Jackson2DatatypeHelper;
import org.springframework.data.rest.webmvc.json.JacksonMappingAwareSortTranslator;
import org.springframework.data.rest.webmvc.json.JacksonSerializers;
import org.springframework.data.rest.webmvc.json.MappingAwareDefaultedPageableArgumentResolver;
import org.springframework.data.rest.webmvc.json.MappingAwarePageableArgumentResolver;
import org.springframework.data.rest.webmvc.json.MappingAwareSortArgumentResolver;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module;
import org.springframework.data.rest.webmvc.json.*;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.LookupObjectSerializer;
import org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaConverter;
import org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaConverter.ValueTypeSchemaPropertyCustomizerFactory;
import org.springframework.data.rest.webmvc.mapping.Associations;
import org.springframework.data.rest.webmvc.mapping.LinkCollector;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter.DefaultIdConverter;
import org.springframework.data.rest.webmvc.support.BackendIdHandlerMethodArgumentResolver;
import org.springframework.data.rest.webmvc.support.DefaultExcerptProjector;
import org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping;
import org.springframework.data.rest.webmvc.support.DomainClassResolver;
import org.springframework.data.rest.webmvc.support.ETagArgumentResolver;
import org.springframework.data.rest.webmvc.support.ExcerptProjector;
import org.springframework.data.rest.webmvc.support.HttpMethodHandlerMethodArgumentResolver;
import org.springframework.data.rest.webmvc.support.JpaHelper;
import org.springframework.data.rest.webmvc.support.PagingAndSortingTemplateVariables;
import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks;
import org.springframework.data.rest.webmvc.support.*;
import org.springframework.data.util.AnnotatedTypeScanner;
import org.springframework.data.util.Lazy;
import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver;
@@ -142,7 +112,6 @@ import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessage
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
@@ -386,7 +355,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
@Bean
public BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver() {
return new BackendIdHandlerMethodArgumentResolver(Java8PluginRegistry.of(backendIdConverterRegistry()),
return new BackendIdHandlerMethodArgumentResolver(backendIdConverterRegistry(),
resourceMetadataHandlerMethodArgumentResolver(), baseUri());
}
@@ -409,7 +378,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
pageableResolver(), sortResolver());
return new RepositoryEntityLinks(repositories(), resourceMappings(), repositoryRestConfiguration(),
templateVariables, Java8PluginRegistry.of(backendIdConverterRegistry()));
templateVariables, backendIdConverterRegistry());
}
/**
@@ -648,8 +617,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
EmbeddedResourcesAssembler assembler = new EmbeddedResourcesAssembler(entities, associationLinks(),
excerptProjector());
LookupObjectSerializer lookupObjectSerializer = new LookupObjectSerializer(
Java8PluginRegistry.of(getEntityLookups()));
LookupObjectSerializer lookupObjectSerializer = new LookupObjectSerializer(PluginRegistry.of(getEntityLookups()));
return new PersistentEntityJackson2Module(associationLinks(), entities, uriToEntityConverter, linkCollector(),
repositoryInvokerFactory, lookupObjectSerializer, resourceProcessorInvoker(), assembler);
@@ -774,7 +742,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
converters.addAll(this.idConverters);
converters.add(DefaultIdConverter.INSTANCE);
return OrderAwarePluginRegistry.create(converters);
return PluginRegistry.of(converters);
}
@Bean

View File

@@ -45,7 +45,6 @@ import org.springframework.data.rest.core.mapping.ResourceMappings;
import org.springframework.data.rest.core.mapping.ResourceMetadata;
import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.SelfLinkProvider;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.EmbeddedResourcesAssembler;
import org.springframework.data.rest.webmvc.PersistentEntityResource;
import org.springframework.data.rest.webmvc.mapping.Associations;
@@ -56,6 +55,7 @@ import org.springframework.hateoas.Links;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.mvc.ResourceProcessorInvoker;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -774,7 +774,7 @@ public class PersistentEntityJackson2Module extends SimpleModule {
public static class LookupObjectSerializer extends ToStringSerializer {
private static final long serialVersionUID = -3033458643050330913L;
private final Java8PluginRegistry<EntityLookup<?>, Class<?>> lookups;
private final PluginRegistry<EntityLookup<?>, Class<?>> lookups;
/*
* (non-Javadoc)

View File

@@ -19,12 +19,12 @@ import java.io.Serializable;
import org.springframework.core.MethodParameter;
import org.springframework.data.rest.core.mapping.ResourceMetadata;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.BaseUri;
import org.springframework.data.rest.webmvc.config.ResourceMetadataHandlerMethodArgumentResolver;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter.DefaultIdConverter;
import org.springframework.data.rest.webmvc.util.UriUtils;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
@@ -39,7 +39,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*/
public class BackendIdHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
private final Java8PluginRegistry<BackendIdConverter, Class<?>> idConverters;
private final PluginRegistry<BackendIdConverter, Class<?>> idConverters;
private final ResourceMetadataHandlerMethodArgumentResolver resourceMetadataResolver;
private final BaseUri baseUri;
@@ -51,7 +51,7 @@ public class BackendIdHandlerMethodArgumentResolver implements HandlerMethodArgu
* @param resourceMetadataResolver the resolver to obtain {@link ResourceMetadata} from, must not be {@literal null}.
* @param baseUri must not be {@literal null}.
*/
public BackendIdHandlerMethodArgumentResolver(Java8PluginRegistry<BackendIdConverter, Class<?>> idConverters,
public BackendIdHandlerMethodArgumentResolver(PluginRegistry<BackendIdConverter, Class<?>> idConverters,
ResourceMetadataHandlerMethodArgumentResolver resourceMetadataResolver, BaseUri baseUri) {
Assert.notNull(idConverters, "Id converters must not be null!");

View File

@@ -35,7 +35,6 @@ import org.springframework.data.rest.core.mapping.ResourceMapping;
import org.springframework.data.rest.core.mapping.ResourceMappings;
import org.springframework.data.rest.core.mapping.ResourceMetadata;
import org.springframework.data.rest.core.mapping.SearchResourceMappings;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.BaseUri;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter;
import org.springframework.data.rest.webmvc.spi.BackendIdConverter.DefaultIdConverter;
@@ -48,6 +47,7 @@ import org.springframework.hateoas.TemplateVariable.VariableType;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.core.AbstractEntityLinks;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@@ -66,7 +66,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks {
private final @NonNull ResourceMappings mappings;
private final @NonNull RepositoryRestConfiguration config;
private final @NonNull PagingAndSortingTemplateVariables templateVariables;
private final @NonNull Java8PluginRegistry<BackendIdConverter, Class<?>> idConverters;
private final @NonNull PluginRegistry<BackendIdConverter, Class<?>> idConverters;
/*
* (non-Javadoc)

View File

@@ -42,7 +42,6 @@ import org.springframework.data.rest.core.UriToEntityConverter;
import org.springframework.data.rest.core.mapping.ResourceMappings;
import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.SelfLinkProvider;
import org.springframework.data.rest.core.util.Java8PluginRegistry;
import org.springframework.data.rest.webmvc.EmbeddedResourcesAssembler;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.AssociationOmittingSerializerModifier;
import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.AssociationUriResolvingDeserializerModifier;
@@ -54,6 +53,7 @@ import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.mvc.ResourceProcessorInvoker;
import org.springframework.plugin.core.PluginRegistry;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -99,7 +99,7 @@ public class PersistentEntityJackson2ModuleUnitTests {
SimpleModule module = new SimpleModule();
module.setSerializerModifier(new AssociationOmittingSerializerModifier(persistentEntities, associations,
nestedEntitySerializer, new LookupObjectSerializer(Java8PluginRegistry.of(Arrays.asList(new HomeLookup())))));
nestedEntitySerializer, new LookupObjectSerializer(PluginRegistry.of(new HomeLookup()))));
module.setDeserializerModifier(
new AssociationUriResolvingDeserializerModifier(persistentEntities, associations, converter, factory));