Class MvcConfig
- java.lang.Object
-
- uk.ac.warwick.dcs.sherlock.module.web.configuration.MvcConfig
-
- All Implemented Interfaces:
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration @EnableConfigurationProperties({SecurityProperties.class,SetupProperties.class,WebmasterProperties.class}) public class MvcConfig extends java.lang.Object implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Enables localisation support and loads the extra properties for Spring's application.properties files
-
-
Constructor Summary
Constructors Constructor Description MvcConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
Adds the above interceptor bean to the application’s interceptor registryorg.springframework.validation.Validator
getValidator()
To use the validation messages from the properties file during model validation we need to register the message source above to the local validator beanorg.springframework.web.servlet.i18n.LocaleChangeInterceptor
localeChangeInterceptor()
An interceptor bean which allows for changing the current locale on every request based on the value of the "lang" parameter appended to a requestorg.springframework.web.servlet.LocaleResolver
localeResolver()
Used to determine which locale is currently being used and sets the defaultorg.springframework.context.MessageSource
messageSource()
Spring delegates the message resolution to this bean and ReloadableResourceBundleMessageSource resolves messages from the resource bundle (messages.properties) for each localeorg.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
passwordEncoder()
Create a password encoder bean that uses the BCrypt strong hashing function-
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
addArgumentResolvers, addCorsMappings, addFormatters, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configurePathMatch, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver
-
-
-
-
Method Detail
-
passwordEncoder
@Bean public org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder passwordEncoder()
Create a password encoder bean that uses the BCrypt strong hashing function- Returns:
- the PasswordEncoder implementation
-
localeResolver
@Bean public org.springframework.web.servlet.LocaleResolver localeResolver()
Used to determine which locale is currently being used and sets the default- Returns:
- the session based locale resolver
-
localeChangeInterceptor
@Bean public org.springframework.web.servlet.i18n.LocaleChangeInterceptor localeChangeInterceptor()
An interceptor bean which allows for changing the current locale on every request based on the value of the "lang" parameter appended to a request- Returns:
- the interceptor object
-
addInterceptors
public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
Adds the above interceptor bean to the application’s interceptor registry- Specified by:
addInterceptors
in interfaceorg.springframework.web.servlet.config.annotation.WebMvcConfigurer
- Parameters:
registry
- which helps with configuring a list of mapped interceptors
-
messageSource
@Bean public org.springframework.context.MessageSource messageSource()
Spring delegates the message resolution to this bean and ReloadableResourceBundleMessageSource resolves messages from the resource bundle (messages.properties) for each locale- Returns:
- the implementation of the MessageSource interface
-
getValidator
@Bean public org.springframework.validation.Validator getValidator()
To use the validation messages from the properties file during model validation we need to register the message source above to the local validator bean- Specified by:
getValidator
in interfaceorg.springframework.web.servlet.config.annotation.WebMvcConfigurer
- Returns:
- the local validator bean with the validation message source set
-
-