Class RepositoryRestMvcConfiguration
java.lang.Object
org.springframework.data.web.config.SpringDataWebConfiguration
org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration
org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,EmbeddedValueResolverAware
,WebMvcConfigurer
@Configuration(proxyBeanMethods=false)
@EnableHypermediaSupport(type={HAL,HAL_FORMS})
@Import({org.springframework.data.rest.webmvc.config.RestControllerImportSelector.class,org.springframework.data.web.config.SpringDataJacksonConfiguration.class,org.springframework.data.web.config.EnableSpringDataWebSupport.QuerydslActivator.class})
public class RepositoryRestMvcConfiguration
extends HateoasAwareSpringDataWebConfiguration
implements BeanClassLoaderAware, EmbeddedValueResolverAware
Main application configuration for Spring Data REST. To customize how the exporter works, subclass this and override
any of the configure* methods.
Any XML files located in the classpath under the META-INF/spring-data-rest/ path will be automatically
found and loaded into this ApplicationContext
.
- Author:
- Oliver Gierke, Jon Brisbin, Greg Turnquist, Mark Paluch, Christoph Strobl, Will Fleury
-
Constructor Summary
ConstructorDescriptionRepositoryRestMvcConfiguration
(ApplicationContext context, ObjectFactory<ConversionService> conversionService, ObjectProvider<LinkRelationProvider> relProvider, ObjectProvider<CurieProvider> curieProvider, ObjectProvider<HalConfiguration> halConfiguration, ObjectProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapper, ObjectProvider<RepresentationModelProcessorInvoker> invoker, ObjectProvider<MessageResolver> resolver, ObjectProvider<GeoModule> geoModule, ObjectProvider<PathPatternParser> parser) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResourceHandlers
(ResourceHandlerRegistry registry) alpsConverter
(Repositories repositories, PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, EnumTranslator enumTranslator, Associations associationLinks, RepositoryRestConfiguration repositoryRestConfiguration) static AnnotatedEventHandlerInvoker
associationLinks
(RepositoryResourceMappings resourceMappings, RepositoryRestConfiguration repositoryRestConfiguration) auditableBeanWrapperFactory
(PersistentEntities persistentEntities) org.springframework.plugin.core.PluginRegistry<BackendIdConverter,
Class<?>> backendIdConverterRegistry
(List<BackendIdConverter> backendIdConverter) backendIdHandlerMethodArgumentResolver
(org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, BaseUri baseUri) baseUri
(RepositoryRestConfiguration repositoryRestConfiguration) protected com.fasterxml.jackson.databind.ObjectMapper
defaultConversionService
(PersistentEntities persistentEntities, RepositoryInvokerFactory repositoryInvokerFactory) defaultMessageConverters
(TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter, TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter, TypeConstrainedMappingJackson2HttpMessageConverter halFormsJacksonHttpMessageConverter, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, UriListHttpMessageConverter uriListHttpMessageConverter, RepositoryRestConfiguration repositoryRestConfiguration) protected List<HandlerMethodArgumentResolver>
defaultMethodArgumentResolvers
(SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver) entityLinks
(ObjectFactory<HateoasPageableHandlerMethodArgumentResolver> pageableResolver, Repositories repositories, RepositoryResourceMappings resourceMappings, org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, RepositoryRestConfiguration repositoryRestConfiguration, ObjectFactory<HateoasSortHandlerMethodArgumentResolver> sortResolver) A specialEntityLinks
implementation that takes repository and current configuration into account when generating links.enumTranslator
(MessageResolver resolver) excerptProjector
(RepositoryResourceMappings resourceMappings) void
extendHandlerExceptionResolvers
(List<HandlerExceptionResolver> exceptionResolvers) protected List<EntityLookup<?>>
halJacksonHttpMessageConverter
(LinkCollector linkCollector, RepositoryRestConfiguration repositoryRestConfiguration) com.fasterxml.jackson.databind.ObjectMapper
halObjectMapper
(LinkCollector linkCollector) httpHeadersPreparer
(AuditableBeanWrapperFactory auditableBeanWrapperFactory) jacksonHttpMessageConverter
(RepositoryRestConfiguration repositoryRestConfiguration) TheHttpMessageConverter
used by Spring MVC to read and write JSON data.jsonSchemaConverter
(PersistentEntities persistentEntities, Associations associationLinks, RepositoryInvokerFactory repositoryInvokerFactory, RepositoryRestConfiguration repositoryRestConfiguration) Turns a domain class into aJsonSchema
.protected LinkCollector
linkCollector
(PersistentEntities persistentEntities, SelfLinkProvider selfLinkProvider, Associations associationLinks) com.fasterxml.jackson.databind.ObjectMapper
The JacksonObjectMapper
used internally.persistentEntityArgumentResolver
(List<HttpMessageConverter<?>> defaultMessageConverters, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, Associations associationLinks, BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver, PersistentEntities entities) Reads incoming JSON into an entity.protected com.fasterxml.jackson.databind.Module
persistentEntityJackson2Module
(LinkCollector linkCollector) Jackson module responsible for intelligently serializing and deserializing JSON that corresponds to an entity.profileResourceProcessor
(RepositoryRestConfiguration repositoryRestConfiguration) static ProjectionDefinitionRegistar
repoRequestArgumentResolver
(Repositories repositories, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, RepositoryInvokerFactory repositoryInvokerFactory) A convenience resolver that pulls together all the information needed to service a request.repositoryExporterHandlerAdapter
(ObjectProvider<Validator> validator, List<HttpMessageConverter<?>> defaultMessageConverters, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, RepositoryRestConfiguration repositoryRestConfiguration) SpecialHandlerAdapter
that only recognizes handler methods defined in the provided controller classes.repositoryRelProvider
(ObjectFactory<ResourceMappings> resourceMappings) <T extends RepositoryRestConfiguration & CorsConfigurationAware>
TMain configuration for the REST exporter.resourceMappings
(Repositories repositories, PersistentEntities persistentEntities, RepositoryRestConfiguration repositoryRestConfiguration) resourceMetadataHandlerMethodArgumentResolver
(Repositories repositories, RepositoryResourceMappings resourceMappings, BaseUri baseUri) org.springframework.data.rest.webmvc.config.DelegatingHandlerMapping
restHandlerMapping
(Repositories repositories, RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper, RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration) TheHandlerMapping
to delegate requests to Spring Data REST controllers.selfLinkProvider
(PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, ObjectProvider<ConversionService> conversionService) void
setBeanClassLoader
(ClassLoader classLoader) void
setEmbeddedValueResolver
(StringValueResolver resolver) TheHttpMessageConverter
used to create text/uri-list responses.ApplicationListener
implementation for invokingValidator
instances assigned to specific domain types.Methods inherited from class org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration
addArgumentResolvers, pagedResourcesAssembler, pagedResourcesAssemblerArgumentResolver, slicedResourcesAssembler, slicedResourcesAssemblerArgumentResolver
Methods inherited from class org.springframework.data.web.config.SpringDataWebConfiguration
addFormatters, customizeOffsetResolver, customizePageableResolver, customizeSortResolver, extendMessageConverters, offsetResolver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
addCorsMappings, addInterceptors, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configurePathMatch, configureViewResolvers, getMessageCodesResolver, getValidator
-
Constructor Details
-
RepositoryRestMvcConfiguration
public RepositoryRestMvcConfiguration(ApplicationContext context, @Qualifier("mvcConversionService") ObjectFactory<ConversionService> conversionService, ObjectProvider<LinkRelationProvider> relProvider, ObjectProvider<CurieProvider> curieProvider, ObjectProvider<HalConfiguration> halConfiguration, ObjectProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapper, ObjectProvider<RepresentationModelProcessorInvoker> invoker, ObjectProvider<MessageResolver> resolver, ObjectProvider<GeoModule> geoModule, ObjectProvider<PathPatternParser> parser)
-
-
Method Details
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
- Overrides:
setBeanClassLoader
in classSpringDataWebConfiguration
-
setEmbeddedValueResolver
- Specified by:
setEmbeddedValueResolver
in interfaceEmbeddedValueResolverAware
-
repositories
-
repositoryRelProvider
@Bean public RepositoryRelProvider repositoryRelProvider(ObjectFactory<ResourceMappings> resourceMappings) -
persistentEntities
-
defaultConversionService
@Bean @Qualifier public DefaultFormattingConversionService defaultConversionService(PersistentEntities persistentEntities, RepositoryInvokerFactory repositoryInvokerFactory) -
validatingRepositoryEventListener
@Bean public ValidatingRepositoryEventListener validatingRepositoryEventListener(ObjectFactory<PersistentEntities> entities) ApplicationListener
implementation for invokingValidator
instances assigned to specific domain types. -
jpaHelper
-
repositoryRestConfiguration
@Bean public <T extends RepositoryRestConfiguration & CorsConfigurationAware> T repositoryRestConfiguration()Main configuration for the REST exporter. -
projectionDefinitionRegistrar
@Bean public static ProjectionDefinitionRegistar projectionDefinitionRegistrar(ObjectFactory<RepositoryRestConfiguration> config) -
metadataConfiguration
-
baseUri
-
annotatedEventHandlerInvoker
-
repoRequestArgumentResolver
@Bean public RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver(Repositories repositories, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, @Qualifier("repositoryInvokerFactory") RepositoryInvokerFactory repositoryInvokerFactory) A convenience resolver that pulls together all the information needed to service a request.- Returns:
-
resourceMetadataHandlerMethodArgumentResolver
@Bean public ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver(Repositories repositories, RepositoryResourceMappings resourceMappings, BaseUri baseUri) -
backendIdHandlerMethodArgumentResolver
@Bean public BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver(org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, BaseUri baseUri) -
eTagArgumentResolver
-
entityLinks
@Bean public RepositoryEntityLinks entityLinks(ObjectFactory<HateoasPageableHandlerMethodArgumentResolver> pageableResolver, Repositories repositories, RepositoryResourceMappings resourceMappings, org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, RepositoryRestConfiguration repositoryRestConfiguration, ObjectFactory<HateoasSortHandlerMethodArgumentResolver> sortResolver) A specialEntityLinks
implementation that takes repository and current configuration into account when generating links.- Returns:
-
persistentEntityArgumentResolver
@Bean public PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver(@Qualifier("defaultMessageConverters") List<HttpMessageConverter<?>> defaultMessageConverters, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, Associations associationLinks, BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver, PersistentEntities entities) Reads incoming JSON into an entity.- Returns:
-
jsonSchemaConverter
@Bean public PersistentEntityToJsonSchemaConverter jsonSchemaConverter(PersistentEntities persistentEntities, Associations associationLinks, @Qualifier("repositoryInvokerFactory") RepositoryInvokerFactory repositoryInvokerFactory, RepositoryRestConfiguration repositoryRestConfiguration) Turns a domain class into aJsonSchema
.- Returns:
-
objectMapper
public com.fasterxml.jackson.databind.ObjectMapper objectMapper()The JacksonObjectMapper
used internally.- Returns:
-
jacksonHttpMessageConverter
@Bean public TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter(RepositoryRestConfiguration repositoryRestConfiguration) TheHttpMessageConverter
used by Spring MVC to read and write JSON data.- Returns:
-
halJacksonHttpMessageConverter
@Bean public TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter(LinkCollector linkCollector, RepositoryRestConfiguration repositoryRestConfiguration) -
halObjectMapper
-
uriListHttpMessageConverter
TheHttpMessageConverter
used to create text/uri-list responses.- Returns:
-
repositoryExporterHandlerAdapter
@Bean public RequestMappingHandlerAdapter repositoryExporterHandlerAdapter(@Qualifier("mvcValidator") ObjectProvider<Validator> validator, @Qualifier("defaultMessageConverters") List<HttpMessageConverter<?>> defaultMessageConverters, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, RepositoryRestConfiguration repositoryRestConfiguration) SpecialHandlerAdapter
that only recognizes handler methods defined in the provided controller classes.- Returns:
-
restHandlerMapping
@Bean public org.springframework.data.rest.webmvc.config.DelegatingHandlerMapping restHandlerMapping(Repositories repositories, RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper, RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration) TheHandlerMapping
to delegate requests to Spring Data REST controllers. Sets up aDelegatingHandlerMapping
to make sure manually implementedBasePathAwareController
instances that register custom handlers for certain media types don't cause theRepositoryRestHandlerMapping
to be omitted. See DATAREST-490.- Returns:
-
resourceMappings
@Bean public RepositoryResourceMappings resourceMappings(Repositories repositories, PersistentEntities persistentEntities, RepositoryRestConfiguration repositoryRestConfiguration) -
persistentEntityJackson2Module
protected com.fasterxml.jackson.databind.Module persistentEntityJackson2Module(LinkCollector linkCollector) Jackson module responsible for intelligently serializing and deserializing JSON that corresponds to an entity.- Returns:
-
linkCollector
@Bean protected LinkCollector linkCollector(PersistentEntities persistentEntities, SelfLinkProvider selfLinkProvider, Associations associationLinks) -
excerptProjector
-
extendHandlerExceptionResolvers
- Specified by:
extendHandlerExceptionResolvers
in interfaceWebMvcConfigurer
-
repositoryRestExceptionHandler
-
repositoryInvokerFactory
-
defaultMessageConverters
@Bean public List<HttpMessageConverter<?>> defaultMessageConverters(@Qualifier("jacksonHttpMessageConverter") TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter, @Qualifier("halJacksonHttpMessageConverter") TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter, @Qualifier("halFormsJacksonHttpMessageConverter") TypeConstrainedMappingJackson2HttpMessageConverter halFormsJacksonHttpMessageConverter, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, UriListHttpMessageConverter uriListHttpMessageConverter, RepositoryRestConfiguration repositoryRestConfiguration) -
alpsJsonHttpMessageConverter
@Bean public AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter(RootResourceInformationToAlpsDescriptorConverter alpsConverter) -
pageableResolver
- Overrides:
pageableResolver
in classHateoasAwareSpringDataWebConfiguration
-
sortResolver
- Overrides:
sortResolver
in classHateoasAwareSpringDataWebConfiguration
-
backendIdConverterRegistry
@Bean public org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> backendIdConverterRegistry(List<BackendIdConverter> backendIdConverter) -
auditableBeanWrapperFactory
@Bean public AuditableBeanWrapperFactory auditableBeanWrapperFactory(PersistentEntities persistentEntities) -
httpHeadersPreparer
@Bean public HttpHeadersPreparer httpHeadersPreparer(AuditableBeanWrapperFactory auditableBeanWrapperFactory) -
selfLinkProvider
@Bean public SelfLinkProvider selfLinkProvider(PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, @Qualifier("mvcConversionService") ObjectProvider<ConversionService> conversionService) -
associationLinks
@Bean public Associations associationLinks(RepositoryResourceMappings resourceMappings, RepositoryRestConfiguration repositoryRestConfiguration) -
getEntityLookups
-
defaultMethodArgumentResolvers
protected List<HandlerMethodArgumentResolver> defaultMethodArgumentResolvers(SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver) -
basicObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper basicObjectMapper() -
enumTranslator
-
alpsConverter
@Bean public RootResourceInformationToAlpsDescriptorConverter alpsConverter(Repositories repositories, PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, EnumTranslator enumTranslator, Associations associationLinks, RepositoryRestConfiguration repositoryRestConfiguration) -
profileResourceProcessor
@Bean public ProfileResourceProcessor profileResourceProcessor(RepositoryRestConfiguration repositoryRestConfiguration) -
addResourceHandlers
- Specified by:
addResourceHandlers
in interfaceWebMvcConfigurer
-