/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.flowable.app.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

import org.flowable.app.rest.idm.remote.RemoteAccountResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@Configuration
@ComponentScan(value = { "org.flowable.app.rest.idm", "org.flowable.app.rest.exception" }, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = RemoteAccountResource.class))
@EnableAsync
public class AppDispatcherServletConfiguration extends WebMvcConfigurationSupport {

    private static final Logger LOGGER = LoggerFactory.getLogger(AppDispatcherServletConfiguration.class);

    @Autowired
    private ObjectMapper objectMapper;

    @Bean
    public SessionLocaleResolver localeResolver() {
        return new SessionLocaleResolver();
    }

    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor() {
        LOGGER.debug("Configuring localeChangeInterceptor");
        LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
        localeChangeInterceptor.setParamName("language");
        return localeChangeInterceptor;
    }

    @Bean
    public RequestMappingHandlerMapping requestMappingHandlerMapping() {
        LOGGER.debug("Creating requestMappingHandlerMapping");
        RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
        requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
        requestMappingHandlerMapping.setRemoveSemicolonContent(false);
        Object[] interceptors = { localeChangeInterceptor() };
        requestMappingHandlerMapping.setInterceptors(interceptors);
        return requestMappingHandlerMapping;
    }

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        addDefaultHttpMessageConverters(converters);
        for (HttpMessageConverter<?> converter : converters) {
            if (converter instanceof MappingJackson2HttpMessageConverter) {
                MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;
                jackson2HttpMessageConverter.setObjectMapper(objectMapper);
                break;
            }
        }
    }
}

@@ -592,85 +592,8 @@
 t;%0A%0A
-import com.fasterxml.jackson.databind.ObjectMapper;%0A%0Aimport java.util.List;%0A%0A
 impo
@@ -740,41 +740,56 @@
 rk.b
-eans.factory.annotation.Autowired
+oot.autoconfigure.web.WebMvcRegistrationsAdapter
 ;%0Aim
@@ -1049,274 +1049,41 @@
 ork.
-http.converter.HttpMessageConverter;%0Aimport org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;%0Aimport org.springframework.scheduling.annotation.EnableAsync;%0Aimport org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
+scheduling.annotation.EnableAsync
 ;%0Aim
@@ -1604,28 +1604,28 @@
 bMvc
-ConfigurationSupport
+RegistrationsAdapter
  %7B%0A%0A
@@ -1736,63 +1736,8 @@
 );%0A%0A
-    @Autowired%0A    private ObjectMapper objectMapper;%0A%0A
     
@@ -2169,34 +2169,24 @@
 tor;%0A    %7D%0A%0A
-    @Bean%0A
     public R
@@ -2205,33 +2205,36 @@
 gHandlerMapping 
-r
+getR
 equestMappingHan
@@ -2742,562 +2742,7 @@
    %7D
-%0A%0A    @Override%0A    public void configureMessageConverters(List%3CHttpMessageConverter%3C?%3E%3E converters) %7B%0A        addDefaultHttpMessageConverters(converters);%0A        for (HttpMessageConverter%3C?%3E converter : converters) %7B%0A            if (converter instanceof MappingJackson2HttpMessageConverter) %7B%0A                MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;%0A                jackson2HttpMessageConverter.setObjectMapper(objectMapper);%0A                break;%0A            %7D%0A        %7D%0A    %7D
 %0A%7D%0A

Use Spring Boot WebMvcRegistrationsAdapter