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

org.zodiac.autoconfigure.web.WebAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.web;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.web.remote.WebRemoteProperties;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.commons.exception.ClassInstantiationException;
import org.zodiac.commons.util.ClassLoaders;
import org.zodiac.commons.util.Classes;

@SpringBootConfiguration
//@ConditionalOnWebApplication
public class WebAutoConfiguration {

    public WebAutoConfiguration() {
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnClass(name = {"org.zodiac.core.web.config.HttpContextInfo"})
    @ConfigurationProperties(prefix = HttpContextProperties.PREFIX, ignoreInvalidFields = true)
    protected HttpContextProperties httpContextProperties() {
        return new HttpContextProperties();
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(name = SystemPropertiesConstants.Zodiac.SPRING_HTTP_CONTEXT_HUMAN_DATE_CONVERTER_ENABLED, havingValue = "true", matchIfMissing = true)
    protected org.zodiac.core.proxy.HumanDateConversionFilter humanDateConversionProcessor() throws ClassNotFoundException, ClassInstantiationException {
        boolean baseEntityPresent = Classes.isPresent("org.zodiac.mybatisplus.base.BaseEntity");
        Object filter = baseEntityPresent ? ClassLoaders.newInstance("org.zodiac.mybatisplus.support.BaseEntityHumanDateConversionFilter") : ClassLoaders.newInstance("org.zodiac.core.proxy.HumanDateConversionFilter");
        return (org.zodiac.core.proxy.HumanDateConversionFilter)filter;
    }

    @Bean
    @ConditionalOnMissingBean
    @ConfigurationProperties(value = SystemPropertiesConstants.Zodiac.SPRING_HTTP_REMOTE_PREFIX)
    protected WebRemoteProperties webRemoteProperties() {
        return new WebRemoteProperties();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy