All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.web.error.AbstractErrorAutoConfiguration Maven / Gradle / Ivy

package org.zodiac.autoconfigure.web.error;

import java.util.List;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.web.HttpContextProperties;
import org.zodiac.commons.web.config.HttpCommonErrorHandlerInfo;
import org.zodiac.core.web.PrefixHandlerMappingSupport;
import org.zodiac.core.web.error.CompositeErrorConfigurer;
import org.zodiac.core.web.error.DefaultErrorConfigurer;
import org.zodiac.core.web.error.ErrorConfigurer;
import org.zodiac.core.web.error.ErrorController;
import org.zodiac.sdk.toolkit.constants.StringPool;

/**
 * Global error controller handler auto configuration.
 * 
 */
public abstract class AbstractErrorAutoConfiguration extends PrefixHandlerMappingSupport {

    protected final HttpCommonErrorHandlerInfo httpCommonErrorHandlerInfo;

    protected AbstractErrorAutoConfiguration(ApplicationContext applicationContext, HttpContextProperties httpContextProperties) {
        super(applicationContext);
        this.httpCommonErrorHandlerInfo = httpContextProperties.getErrorHandler();
    }

    @Bean
    @ConditionalOnMissingBean
    protected DefaultErrorConfigurer defaultErrorConfigurer() {
        return new DefaultErrorConfigurer(httpCommonErrorHandlerInfo);
    }

    @Bean
    @ConditionalOnMissingBean
    protected CompositeErrorConfigurer compositeErrorConfigurer(List configures) {
        return new CompositeErrorConfigurer(httpCommonErrorHandlerInfo, configures);
    }

    @Bean
    protected Object errorHandlerPrefixHandlerMapping() {
        return super.newPrefixHandlerMapping(StringPool.SLASH, ErrorController.class);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy