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:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.EmbeddedValueResolverAware, org.springframework.web.servlet.config.annotation.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 org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration implements org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.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 Details

    • RepositoryRestMvcConfiguration

      public RepositoryRestMvcConfiguration(org.springframework.context.ApplicationContext context, @Qualifier("mvcConversionService") org.springframework.beans.factory.ObjectFactory<org.springframework.core.convert.ConversionService> conversionService, org.springframework.beans.factory.ObjectProvider<org.springframework.hateoas.server.LinkRelationProvider> relProvider, org.springframework.beans.factory.ObjectProvider<org.springframework.hateoas.mediatype.hal.CurieProvider> curieProvider, org.springframework.beans.factory.ObjectProvider<org.springframework.hateoas.mediatype.hal.HalConfiguration> halConfiguration, org.springframework.beans.factory.ObjectProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapper, org.springframework.beans.factory.ObjectProvider<org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker> invoker, org.springframework.beans.factory.ObjectProvider<org.springframework.hateoas.mediatype.MessageResolver> resolver, org.springframework.beans.factory.ObjectProvider<org.springframework.data.geo.GeoModule> geoModule, org.springframework.beans.factory.ObjectProvider<org.springframework.web.util.pattern.PathPatternParser> parser)
  • Method Details

    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
      Overrides:
      setBeanClassLoader in class org.springframework.data.web.config.SpringDataWebConfiguration
    • setEmbeddedValueResolver

      public void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
      Specified by:
      setEmbeddedValueResolver in interface org.springframework.context.EmbeddedValueResolverAware
    • repositories

      @Bean public org.springframework.data.repository.support.Repositories repositories()
    • repositoryRelProvider

      @Bean public RepositoryRelProvider repositoryRelProvider(org.springframework.beans.factory.ObjectFactory<ResourceMappings> resourceMappings)
    • persistentEntities

      @Bean public org.springframework.data.mapping.context.PersistentEntities persistentEntities()
    • defaultConversionService

      @Bean @Qualifier public org.springframework.format.support.DefaultFormattingConversionService defaultConversionService(org.springframework.data.mapping.context.PersistentEntities persistentEntities, org.springframework.data.repository.support.RepositoryInvokerFactory repositoryInvokerFactory, org.springframework.data.repository.support.Repositories repositories)
    • validatingRepositoryEventListener

      @Bean public ValidatingRepositoryEventListener validatingRepositoryEventListener(org.springframework.beans.factory.ObjectFactory<org.springframework.data.mapping.context.PersistentEntities> entities)
      ApplicationListener implementation for invoking Validator instances assigned to specific domain types.
    • jpaHelper

      @Bean public JpaHelper jpaHelper()
    • repositoryRestConfiguration

      @Bean public <T extends RepositoryRestConfiguration & CorsConfigurationAware> T repositoryRestConfiguration()
      Main configuration for the REST exporter.
    • projectionDefinitionRegistrar

      @Bean public static ProjectionDefinitionRegistar projectionDefinitionRegistrar(org.springframework.beans.factory.ObjectFactory<RepositoryRestConfiguration> config)
    • metadataConfiguration

      @Bean public MetadataConfiguration metadataConfiguration()
    • baseUri

      @Bean public BaseUri baseUri(RepositoryRestConfiguration repositoryRestConfiguration)
    • annotatedEventHandlerInvoker

      @Bean public static AnnotatedEventHandlerInvoker annotatedEventHandlerInvoker()
    • serverHttpRequestMethodArgumentResolver

      @Bean public ServerHttpRequestMethodArgumentResolver serverHttpRequestMethodArgumentResolver()
      Turns an HttpServletRequest into a ServerHttpRequest.
      Returns:
    • repoRequestArgumentResolver

      @Bean public RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver(org.springframework.data.repository.support.Repositories repositories, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, @Qualifier("repositoryInvokerFactory") org.springframework.data.repository.support.RepositoryInvokerFactory repositoryInvokerFactory)
      A convenience resolver that pulls together all the information needed to service a request.
      Returns:
    • resourceMetadataHandlerMethodArgumentResolver

      @Bean public ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver(org.springframework.data.repository.support.Repositories repositories, RepositoryResourceMappings resourceMappings, BaseUri baseUri)
    • backendIdHandlerMethodArgumentResolver

      @Bean public BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver(org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> backendIdConverterRegistry, ResourceMetadataHandlerMethodArgumentResolver resourceMetadataHandlerMethodArgumentResolver, BaseUri baseUri)
    • eTagArgumentResolver

      @Bean public ETagArgumentResolver eTagArgumentResolver()
    • entityLinks

      @Bean public RepositoryEntityLinks entityLinks(org.springframework.beans.factory.ObjectFactory<org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver> pageableResolver, org.springframework.data.repository.support.Repositories repositories, RepositoryResourceMappings resourceMappings, org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> backendIdConverterRegistry, RepositoryRestConfiguration repositoryRestConfiguration, org.springframework.beans.factory.ObjectFactory<org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver> sortResolver)
      A special EntityLinks implementation that takes repository and current configuration into account when generating links.
      Returns:
    • persistentEntityArgumentResolver

      @Bean public PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver(@Qualifier("defaultMessageConverters") List<org.springframework.http.converter.HttpMessageConverter<?>> defaultMessageConverters, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, Associations associationLinks, BackendIdHandlerMethodArgumentResolver backendIdHandlerMethodArgumentResolver, org.springframework.data.mapping.context.PersistentEntities entities)
      Reads incoming JSON into an entity.
      Returns:
    • jsonSchemaConverter

      @Bean public PersistentEntityToJsonSchemaConverter jsonSchemaConverter(org.springframework.data.mapping.context.PersistentEntities persistentEntities, Associations associationLinks, @Qualifier("repositoryInvokerFactory") org.springframework.data.repository.support.RepositoryInvokerFactory repositoryInvokerFactory, RepositoryRestConfiguration repositoryRestConfiguration)
      Turns a domain class into a JsonSchema.
      Returns:
    • objectMapper

      public com.fasterxml.jackson.databind.ObjectMapper objectMapper()
      The Jackson ObjectMapper used internally.
      Returns:
    • jacksonHttpMessageConverter

      @Bean public org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter(RepositoryRestConfiguration repositoryRestConfiguration)
      The HttpMessageConverter used by Spring MVC to read and write JSON data.
      Returns:
    • halJacksonHttpMessageConverter

      @Bean public org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter(LinkCollector linkCollector, RepositoryRestConfiguration repositoryRestConfiguration)
    • halObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper halObjectMapper(LinkCollector linkCollector)
    • uriListHttpMessageConverter

      @Bean public UriListHttpMessageConverter uriListHttpMessageConverter()
      The HttpMessageConverter used to create text/uri-list responses.
      Returns:
    • repositoryExporterHandlerAdapter

      @Bean public org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter repositoryExporterHandlerAdapter(@Qualifier("mvcValidator") org.springframework.beans.factory.ObjectProvider<org.springframework.validation.Validator> validator, @Qualifier("defaultMessageConverters") List<org.springframework.http.converter.HttpMessageConverter<?>> defaultMessageConverters, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver, RepositoryRestConfiguration repositoryRestConfiguration)
      Special HandlerAdapter that only recognizes handler methods defined in the provided controller classes.
      Returns:
    • restHandlerMapping

      @Bean public org.springframework.data.rest.webmvc.config.DelegatingHandlerMapping restHandlerMapping(org.springframework.data.repository.support.Repositories repositories, RepositoryResourceMappings resourceMappings, Optional<JpaHelper> jpaHelper, RepositoryRestConfiguration repositoryRestConfiguration, CorsConfigurationAware corsRestConfiguration)
      The HandlerMapping to delegate requests to Spring Data REST controllers. Sets up a DelegatingHandlerMapping to make sure manually implemented BasePathAwareController instances that register custom handlers for certain media types don't cause the RepositoryRestHandlerMapping to be omitted. See DATAREST-490.
      Returns:
    • resourceMappings

      @Bean public RepositoryResourceMappings resourceMappings(org.springframework.data.repository.support.Repositories repositories, org.springframework.data.mapping.context.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(org.springframework.data.mapping.context.PersistentEntities persistentEntities, SelfLinkProvider selfLinkProvider, Associations associationLinks)
    • excerptProjector

      @Bean public ExcerptProjector excerptProjector(RepositoryResourceMappings resourceMappings)
    • extendHandlerExceptionResolvers

      public void extendHandlerExceptionResolvers(List<org.springframework.web.servlet.HandlerExceptionResolver> exceptionResolvers)
      Specified by:
      extendHandlerExceptionResolvers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
    • repositoryRestExceptionHandler

      @Bean public RepositoryRestExceptionHandler repositoryRestExceptionHandler()
    • repositoryInvokerFactory

      @Bean @Qualifier public org.springframework.data.repository.support.RepositoryInvokerFactory repositoryInvokerFactory()
    • defaultMessageConverters

      @Bean public List<org.springframework.http.converter.HttpMessageConverter<?>> defaultMessageConverters(@Qualifier("jacksonHttpMessageConverter") org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter jacksonHttpMessageConverter, @Qualifier("halJacksonHttpMessageConverter") org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter, @Qualifier("halFormsJacksonHttpMessageConverter") org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter halFormsJacksonHttpMessageConverter, AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter, UriListHttpMessageConverter uriListHttpMessageConverter, RepositoryRestConfiguration repositoryRestConfiguration)
    • alpsJsonHttpMessageConverter

      @Bean public AlpsJsonHttpMessageConverter alpsJsonHttpMessageConverter(RootResourceInformationToAlpsDescriptorConverter alpsConverter)
    • pageableResolver

      @Bean public org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver pageableResolver()
      Overrides:
      pageableResolver in class org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration
    • sortResolver

      @Bean public org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver sortResolver()
      Overrides:
      sortResolver in class org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration
    • backendIdConverterRegistry

      @Bean public org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> backendIdConverterRegistry(List<BackendIdConverter> backendIdConverter)
    • auditableBeanWrapperFactory

      @Bean public org.springframework.data.auditing.AuditableBeanWrapperFactory auditableBeanWrapperFactory(org.springframework.data.mapping.context.PersistentEntities persistentEntities)
    • httpHeadersPreparer

      @Bean public HttpHeadersPreparer httpHeadersPreparer(org.springframework.data.auditing.AuditableBeanWrapperFactory auditableBeanWrapperFactory)
    • selfLinkProvider

      @Bean public SelfLinkProvider selfLinkProvider(org.springframework.data.mapping.context.PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, @Qualifier("mvcConversionService") org.springframework.beans.factory.ObjectProvider<org.springframework.core.convert.ConversionService> conversionService)
    • associationLinks

      @Bean public Associations associationLinks(RepositoryResourceMappings resourceMappings, RepositoryRestConfiguration repositoryRestConfiguration)
    • getEntityLookups

      protected List<EntityLookup<?>> getEntityLookups()
    • defaultMethodArgumentResolvers

      protected List<org.springframework.web.method.support.HandlerMethodArgumentResolver> defaultMethodArgumentResolvers(SelfLinkProvider selfLinkProvider, PersistentEntityResourceHandlerMethodArgumentResolver persistentEntityArgumentResolver, RootResourceInformationHandlerMethodArgumentResolver repoRequestArgumentResolver)
    • basicObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper basicObjectMapper()
    • enumTranslator

      @Bean public EnumTranslator enumTranslator(org.springframework.hateoas.mediatype.MessageResolver resolver)
    • alpsConverter

      @Bean public RootResourceInformationToAlpsDescriptorConverter alpsConverter(org.springframework.data.repository.support.Repositories repositories, org.springframework.data.mapping.context.PersistentEntities persistentEntities, RepositoryEntityLinks entityLinks, EnumTranslator enumTranslator, Associations associationLinks, RepositoryRestConfiguration repositoryRestConfiguration)
    • profileResourceProcessor

      @Bean public ProfileResourceProcessor profileResourceProcessor(RepositoryRestConfiguration repositoryRestConfiguration)
    • addResourceHandlers

      public void addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry)
      Specified by:
      addResourceHandlers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer