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

org.zodiac.autoconfigure.boot.servlet.PlatformRequestServletAutoConfiguration Maven / Gradle / Ivy

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringBootConfiguration;
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.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.zodiac.autoconfigure.boot.PlatformRequestProperties;
import org.zodiac.autoconfigure.boot.condition.ConditionalOnPatformRequestEnabled;

/**
 * 过滤器配置类。
 *
 */
@ConditionalOnPatformRequestEnabled
@ConditionalOnWebApplication(type = Type.SERVLET)
@SpringBootConfiguration
@ConditionalOnClass(value = {org.zodiac.boot.ctrl.PlatformRemoteService.class, javax.servlet.Servlet.class, org.springframework.web.servlet.DispatcherServlet.class})
public class PlatformRequestServletAutoConfiguration {

    protected final Logger log = LoggerFactory.getLogger(getClass());

    private final PlatformRequestProperties platformRequestProperties;

    public PlatformRequestServletAutoConfiguration(PlatformRequestProperties platformRequestProperties) {
        this.platformRequestProperties = platformRequestProperties;
        log.info("{} loaded.", getClass().getCanonicalName());
    }

    /**
     * 全局过滤器。
     * 
     * @return 过滤器定义类
     */
    @Bean
    protected FilterRegistrationBean platformFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean<>();
        registration.setDispatcherTypes(javax.servlet.DispatcherType.REQUEST);
        registration.setFilter(new org.zodiac.boot.request.PlatformServletRequestFilter(platformRequestProperties));
        registration.addUrlPatterns("/*");
        registration.setName("platformRequestFilter");
        registration.setOrder(Ordered.LOWEST_PRECEDENCE);
        return registration;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy