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

org.zodiac.autoconfigure.web.ui.WebUiExtensionServerAutoConfguration Maven / Gradle / Ivy

package org.zodiac.autoconfigure.web.ui;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.web.condition.ConditionalOnWebUiExtensionEnabled;

@SpringBootConfiguration
@ConditionalOnWebUiExtensionEnabled
@ConditionalOnClass(value = {org.zodiac.webui.config.WebUiExtensionInfo.class})
public class WebUiExtensionServerAutoConfguration {

    private static final Logger LOG = LoggerFactory.getLogger(WebUiExtensionServerAutoConfguration.class);

    public WebUiExtensionServerAutoConfguration() {
        LOG.info("{} loaded.", getClass().getCanonicalName());
    }

    @SpringBootConfiguration
    @ConditionalOnWebUiExtensionEnabled
    @ConditionalOnWebApplication(type = Type.REACTIVE)
    public static class ReactiveRestApiConfiguration {

        private final WebUiExtensionProperties webUiConfigProperties;

        public ReactiveRestApiConfiguration(WebUiExtensionProperties webUiConfigProperties) {
            this.webUiConfigProperties = webUiConfigProperties;
            LOG.info("{} loaded.", getClass().getCanonicalName());
        }

        @Bean
        @ConditionalOnClass( value = {org.springframework.web.reactive.accept.RequestedContentTypeResolver.class})
        protected org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping webUiControllerHandlerMapping(
            org.springframework.web.reactive.accept.RequestedContentTypeResolver webFluxContentTypeResolver) {
            org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping mapping = new org.zodiac.webui.reactive.WebUiControllerHandlerMapping(
                    this.webUiConfigProperties.getContextPath());
            mapping.setOrder(0);
            mapping.setContentTypeResolver(webFluxContentTypeResolver);
            return mapping;
        }

    }

    @SpringBootConfiguration
    @ConditionalOnWebUiExtensionEnabled
    @ConditionalOnWebApplication(type = Type.SERVLET)
    @AutoConfigureAfter(value = {WebMvcAutoConfiguration.class})
    public static class ServletRestApiConfirguation {

        private final WebUiExtensionProperties webUiConfigProperties;

        public ServletRestApiConfirguation(WebUiExtensionProperties webUiConfigProperties) {
            this.webUiConfigProperties = webUiConfigProperties;
            LOG.info("{} loaded.", getClass().getCanonicalName());
        }
 
        @Bean
        @ConditionalOnClass(value = {org.springframework.web.accept.ContentNegotiationManager.class})
        protected org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping webUiControllerHandlerMapping(
            org.springframework.web.accept.ContentNegotiationManager contentNegotiationManager) {
            org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping mapping = new org.zodiac.webui.servlet.WebUiControllerHandlerMapping(
                    this.webUiConfigProperties.getContextPath());
            mapping.setOrder(0);
            mapping.setContentNegotiationManager(contentNegotiationManager);
            return mapping;
        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy