org.appng.api.config

## Class RestConfig

- java.lang.Object
- - org.appng.api.config.RestConfig

- All Implemented Interfaces:
    org.springframework.beans.factory.config.BeanFactoryPostProcessor
  Direct Known Subclasses:
    RestTestConfig

      @Configuration
      public class RestConfig
      extends Object
      implements org.springframework.beans.factory.config.BeanFactoryPostProcessor

  A `Configuration`that adds a `MappingJackson2HttpMessageConverter` and an `ObjectMapper` to the context, if not already present.
  Also checks the context for Jackson `Module`s and adds them to the `ObjectMapper`.
  Additionally, modules for handling these `Temporal`-types are registered:
  - `OffsetDateTime`, using `DateTimeFormatter.ISO_OFFSET_DATE_TIME`
  - `LocalDate`, using `DateTimeFormatter.ISO_LOCAL_DATE`
  - `LocalTime`, using `DateTimeFormatter.ISO_LOCAL_TIME`
  - `LocalDateTime`, using `DateTimeFormatter.ISO_LOCAL_DATE_TIME`
  Also adds a `HandlerMethodArgumentResolver` that can resolve the current `Environment`, `Site` and `Application`.
  Author:
    Matthias Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RestConfig.SiteAwareHandlerMethodArgumentResolver` A `HandlerMethodArgumentResolver` that can resolve the current `Application`, `Environment` and `Site`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RestConfig()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addDateModules(com.fasterxml.jackson.databind.ObjectMapper objectMapper)`
    `org.springframework.http.converter.ByteArrayHttpMessageConverter` | `byteArrayHttpMessageConverter()`
    `static List<org.springframework.web.method.support.HandlerMethodArgumentResolver>` | `getArgumentResolvers(org.springframework.context.ApplicationContext context)`
    `protected <T extends Temporal> com.fasterxml.jackson.databind.module.SimpleModule` | `getDateModule(Class<T> temporal, Function<String,T> parseFunction, DateTimeFormatter formatter)`
    `static List<org.springframework.http.converter.HttpMessageConverter<?>>` | `getMessageConverters(org.springframework.context.ApplicationContext context)`
    `protected <T> T` | `getPrimaryOrFirst(Map<String,T> beans, Map<String,Object> primaryBeans)`
    `void` | `postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)`
    `RestConfig.SiteAwareHandlerMethodArgumentResolver` | `siteAwareHandlerMethodArgumentResolver(Site site, Application application, Environment environment)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RestConfig

          public RestConfig()

  - ### Method Detail

    - #### getMessageConverters

          public static List<org.springframework.http.converter.HttpMessageConverter<?>> getMessageConverters(org.springframework.context.ApplicationContext context)

    - #### getArgumentResolvers

          public static List<org.springframework.web.method.support.HandlerMethodArgumentResolver> getArgumentResolvers(org.springframework.context.ApplicationContext context)

    - #### postProcessBeanFactory

          public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
                                      throws org.springframework.beans.BeansException

      Specified by:
        `postProcessBeanFactory` in interface `org.springframework.beans.factory.config.BeanFactoryPostProcessor`
      Throws:
        `org.springframework.beans.BeansException`

    - #### getPrimaryOrFirst

          protected <T> T getPrimaryOrFirst(Map<String,T> beans,
                                            Map<String,Object> primaryBeans)

    - #### addDateModules

          protected void addDateModules(com.fasterxml.jackson.databind.ObjectMapper objectMapper)

    - #### getDateModule

          protected <T extends Temporal> com.fasterxml.jackson.databind.module.SimpleModule getDateModule(Class<T> temporal,
                                                                                                          Function<String,T> parseFunction,
                                                                                                          DateTimeFormatter formatter)

    - #### byteArrayHttpMessageConverter

          @Bean
          public org.springframework.http.converter.ByteArrayHttpMessageConverter byteArrayHttpMessageConverter()

    - #### siteAwareHandlerMethodArgumentResolver

          @Bean
           @Lazy
           @RequestScope(proxyMode=NO)
          public RestConfig.SiteAwareHandlerMethodArgumentResolver siteAwareHandlerMethodArgumentResolver(Site site,
                                                                                                                                                    Application application,
                                                                                                                                                    Environment environment)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.