Module spring.data.rest.webmvc
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
ConstructorsConstructorDescriptionRepositoryRestMvcConfiguration(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 TypeMethodDescriptionvoidaddResourceHandlers(ResourceHandlerRegistry registry) alpsConverter(Repositories repositories, PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, EnumTranslator enumTranslator, Associations associationLinks, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) static org.springframework.data.rest.core.event.AnnotatedEventHandlerInvokerassociationLinks(org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, org.springframework.data.rest.core.config.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(org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) protected com.fasterxml.jackson.databind.ObjectMapperdefaultConversionService(PersistentEntities persistentEntities, RepositoryInvokerFactory repositoryInvokerFactory) defaultMessageConverters(TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter, TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter, TypeConstrainedMappingJackson2HttpMessageConverter halFormsJacksonHttpMessageConverter, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, UriListHttpMessageConverter uriListHttpMessageConverter, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) protected List<HandlerMethodArgumentResolver>defaultMethodArgumentResolvers(org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver) entityLinks(ObjectFactory<HateoasPageableHandlerMethodArgumentResolver> pageableResolver, Repositories repositories, org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration, ObjectFactory<HateoasSortHandlerMethodArgumentResolver> sortResolver) A specialEntityLinksimplementation that takes repository and current configuration into account when generating links.enumTranslator(MessageResolver resolver) excerptProjector(org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings) voidextendHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) protected List<org.springframework.data.rest.core.support.EntityLookup<?>>halJacksonHttpMessageConverter(LinkCollector linkCollector, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) com.fasterxml.jackson.databind.ObjectMapperhalObjectMapper(LinkCollector linkCollector) httpHeadersPreparer(AuditableBeanWrapperFactory auditableBeanWrapperFactory) jacksonHttpMessageConverter(org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) TheHttpMessageConverterused by Spring MVC to read and write JSON data.jsonSchemaConverter(PersistentEntities persistentEntities, Associations associationLinks, RepositoryInvokerFactory repositoryInvokerFactory, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) Turns a domain class into aJsonSchema.protected LinkCollectorlinkCollector(PersistentEntities persistentEntities, org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider, Associations associationLinks) org.springframework.data.rest.core.config.MetadataConfigurationcom.fasterxml.jackson.databind.ObjectMapperThe JacksonObjectMapperused internally.persistentEntityArgumentResolver(List<HttpMessageConverter<?>> defaultMessageConverters, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, Associations associationLinks, BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver, PersistentEntities entities) Reads incoming JSON into an entity.protected com.fasterxml.jackson.databind.ModulepersistentEntityJackson2Module(LinkCollector linkCollector) Jackson module responsible for intelligently serializing and deserializing JSON that corresponds to an entity.profileResourceProcessor(org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) static ProjectionDefinitionRegistarprojectionDefinitionRegistrar(ObjectFactory<org.springframework.data.rest.core.config.RepositoryRestConfiguration> config) 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, org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) SpecialHandlerAdapterthat only recognizes handler methods defined in the provided controller classes.org.springframework.data.rest.core.support.RepositoryRelProviderrepositoryRelProvider(ObjectFactory<org.springframework.data.rest.core.mapping.ResourceMappings> resourceMappings) <T extends org.springframework.data.rest.core.config.RepositoryRestConfiguration & CorsConfigurationAware>
TMain configuration for the REST exporter.org.springframework.data.rest.core.mapping.RepositoryResourceMappingsresourceMappings(Repositories repositories, PersistentEntities persistentEntities, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) resourceMetadataHandlerMethodArgumentResolver(Repositories repositories, org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, BaseUri baseUri) org.springframework.data.rest.webmvc.config.DelegatingHandlerMappingrestHandlerMapping(Repositories repositories, org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration) TheHandlerMappingto delegate requests to Spring Data REST controllers.org.springframework.data.rest.core.support.SelfLinkProviderselfLinkProvider(PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, ObjectProvider<ConversionService> conversionService) voidsetBeanClassLoader(ClassLoader classLoader) voidsetEmbeddedValueResolver(StringValueResolver resolver) TheHttpMessageConverterused to create text/uri-list responses.org.springframework.data.rest.core.event.ValidatingRepositoryEventListenerApplicationListenerimplementation for invokingValidatorinstances assigned to specific domain types.Methods inherited from class org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration
addArgumentResolvers, pagedResourcesAssembler, pagedResourcesAssemblerArgumentResolver, slicedResourcesAssembler, slicedResourcesAssemblerArgumentResolverMethods inherited from class org.springframework.data.web.config.SpringDataWebConfiguration
addFormatters, customizeOffsetResolver, customizePageableResolver, customizeSortResolver, extendMessageConverters, offsetResolverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
setBeanClassLoaderin interfaceBeanClassLoaderAware- Overrides:
setBeanClassLoaderin classSpringDataWebConfiguration
-
setEmbeddedValueResolver
- Specified by:
setEmbeddedValueResolverin interfaceEmbeddedValueResolverAware
-
repositories
-
repositoryRelProvider
@Bean public org.springframework.data.rest.core.support.RepositoryRelProvider repositoryRelProvider(ObjectFactory<org.springframework.data.rest.core.mapping.ResourceMappings> resourceMappings) -
persistentEntities
-
defaultConversionService
@Bean @Qualifier public DefaultFormattingConversionService defaultConversionService(PersistentEntities persistentEntities, RepositoryInvokerFactory repositoryInvokerFactory) -
validatingRepositoryEventListener
@Bean public org.springframework.data.rest.core.event.ValidatingRepositoryEventListener validatingRepositoryEventListener(ObjectFactory<PersistentEntities> entities) ApplicationListenerimplementation for invokingValidatorinstances assigned to specific domain types. -
jpaHelper
-
repositoryRestConfiguration
@Bean public <T extends org.springframework.data.rest.core.config.RepositoryRestConfiguration & CorsConfigurationAware> T repositoryRestConfiguration()Main configuration for the REST exporter. -
projectionDefinitionRegistrar
@Bean public static ProjectionDefinitionRegistar projectionDefinitionRegistrar(ObjectFactory<org.springframework.data.rest.core.config.RepositoryRestConfiguration> config) -
metadataConfiguration
@Bean public org.springframework.data.rest.core.config.MetadataConfiguration metadataConfiguration() -
baseUri
-
annotatedEventHandlerInvoker
@Bean public static org.springframework.data.rest.core.event.AnnotatedEventHandlerInvoker 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, org.springframework.data.rest.core.mapping.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, org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, org.springframework.plugin.core.PluginRegistry<BackendIdConverter, Class<?>> backendIdConverterRegistry, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration, ObjectFactory<HateoasSortHandlerMethodArgumentResolver> sortResolver) A specialEntityLinksimplementation 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, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) Turns a domain class into aJsonSchema.- Returns:
-
objectMapper
public com.fasterxml.jackson.databind.ObjectMapper objectMapper()The JacksonObjectMapperused internally.- Returns:
-
jacksonHttpMessageConverter
@Bean public TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter(org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) TheHttpMessageConverterused by Spring MVC to read and write JSON data.- Returns:
-
halJacksonHttpMessageConverter
@Bean public TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter(LinkCollector linkCollector, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) -
halObjectMapper
-
uriListHttpMessageConverter
TheHttpMessageConverterused to create text/uri-list responses.- Returns:
-
repositoryExporterHandlerAdapter
@Bean public RequestMappingHandlerAdapter repositoryExporterHandlerAdapter(@Qualifier("mvcValidator") ObjectProvider<Validator> validator, @Qualifier("defaultMessageConverters") List<HttpMessageConverter<?>> defaultMessageConverters, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) SpecialHandlerAdapterthat only recognizes handler methods defined in the provided controller classes.- Returns:
-
restHandlerMapping
@Bean public org.springframework.data.rest.webmvc.config.DelegatingHandlerMapping restHandlerMapping(Repositories repositories, org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration) TheHandlerMappingto delegate requests to Spring Data REST controllers. Sets up aDelegatingHandlerMappingto make sure manually implementedBasePathAwareControllerinstances that register custom handlers for certain media types don't cause theRepositoryRestHandlerMappingto be omitted. See DATAREST-490.- Returns:
-
resourceMappings
@Bean public org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings(Repositories repositories, PersistentEntities persistentEntities, org.springframework.data.rest.core.config.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, org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider, Associations associationLinks) -
excerptProjector
@Bean public ExcerptProjector excerptProjector(org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings) -
extendHandlerExceptionResolvers
- Specified by:
extendHandlerExceptionResolversin 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, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) -
alpsJsonHttpMessageConverter
@Bean public AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter(RootResourceInformationToAlpsDescriptorConverter alpsConverter) -
pageableResolver
- Overrides:
pageableResolverin classHateoasAwareSpringDataWebConfiguration
-
sortResolver
- Overrides:
sortResolverin 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 org.springframework.data.rest.core.support.SelfLinkProvider selfLinkProvider(PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, @Qualifier("mvcConversionService") ObjectProvider<ConversionService> conversionService) -
associationLinks
@Bean public Associations associationLinks(org.springframework.data.rest.core.mapping.RepositoryResourceMappings resourceMappings, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) -
getEntityLookups
-
defaultMethodArgumentResolvers
protected List<HandlerMethodArgumentResolver> defaultMethodArgumentResolvers(org.springframework.data.rest.core.support.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, org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) -
profileResourceProcessor
@Bean public ProfileResourceProcessor profileResourceProcessor(org.springframework.data.rest.core.config.RepositoryRestConfiguration repositoryRestConfiguration) -
addResourceHandlers
- Specified by:
addResourceHandlersin interfaceWebMvcConfigurer
-