Class Configuration

java.lang.Object
de.gustavblass.fsu.fmi.roombooking.configuration.Configuration
All Implemented Interfaces:
org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@EnableAsync @Configuration public class Configuration extends Object implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Specifies the behaviour of the Spring application.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final @NonNull Locale
    Default language that all pages shall be rendered in if no locale is explicitly specified: German.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull org.thymeleaf.TemplateEngine
     
    void
    configurePathMatch(@NonNull org.springframework.web.servlet.config.annotation.PathMatchConfigurer configurer)
    Allows trailing slashes, so that appending a / to a path (that is not a file) does not matter.
    @NonNull org.springframework.web.servlet.LocaleResolver
    Registers a RootDirectoryBasedLocaleContextResolver as the LocaleResolver.
    @NonNull com.transferwise.icu.ICUMessageSource
    Sets up an ICUMessageSource as the MessageSource used to translate web pages.
    @NonNull PathLocaliser
    pathLocaliser(@NonNull org.springframework.context.MessageSource messageSource)
    Creates a PathLocaliser suitable to convert translated strings into URIs.

    Methods inherited from class Object

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

    Methods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer

    addArgumentResolvers, addCorsMappings, addErrorResponseInterceptors, addFormatters, addInterceptors, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver, getValidator
  • Field Details

    • DEFAULT_LOCALE

      @NonNull private static final @NonNull Locale DEFAULT_LOCALE
      Default language that all pages shall be rendered in if no locale is explicitly specified: German.
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • configurePathMatch

      public void configurePathMatch(@NonNull @NonNull org.springframework.web.servlet.config.annotation.PathMatchConfigurer configurer)
      Allows trailing slashes, so that appending a / to a path (that is not a file) does not matter. Without this setting, /rooms/ would return 404 even if /rooms exists.
      Specified by:
      configurePathMatch in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
      Parameters:
      configurer - Used to allow trailing slashes.
      Implementation Note:
      The current way of implementation is deprecated, but it's the most straightforward way. Also, the other options appear to be overly difficult to implement.
    • localeResolver

      @Bean @NonNull public @NonNull org.springframework.web.servlet.LocaleResolver localeResolver()

      Registers a RootDirectoryBasedLocaleContextResolver as the LocaleResolver. This means that the right language – which a page shall be displayed in – is not determined by headers, cookies or URL parameters, but only by the language code included in the respective URL path.

      Uses DEFAULT_LOCALE as the standard language.

      Returns:
      A RootDirectoryBasedLocaleContextResolver.
    • messageSource

      @Bean @NonNull public @NonNull com.transferwise.icu.ICUMessageSource messageSource()

      Sets up an ICUMessageSource as the MessageSource used to translate web pages. The advantage of ICU is that it does not just allow arguments, but also plurals. See the ICU-TC home page for reference.

      Specifies the following base names inside the i18n resource folder as the source files:

      • error
      • messages
      • reservation
      • room
      • user
      • `validation``

      @return The ICUMessageSource used for i18n (internationalisation).`

    • additionalDialects

      @Bean @NonNull public @NonNull org.thymeleaf.TemplateEngine additionalDialects()
      Returns:

      A TemplateEngine which includes

      • a SpringSecurityDialect that enables the use of sec:authorize in Thymeleaf templates
      • and a LayoutDialect to use base layouts.
      See Also:
    • pathLocaliser

      @Bean @NonNull public @NonNull PathLocaliser pathLocaliser(@NonNull @NonNull org.springframework.context.MessageSource messageSource)
      Creates a PathLocaliser suitable to convert translated strings into URIs.
      Parameters:
      messageSource - Used by the PathLocaliser to resolve given path codes.
      Returns:
      The PathLocaliser.