Search in sources :

Example 1 with DruidStatProperties

use of com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties in project druid by alibaba.

the class DruidStatViewServletConfiguration method statViewServletRegistrationBean.

@Bean
public ServletRegistrationBean statViewServletRegistrationBean(DruidStatProperties properties) {
    DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
    ServletRegistrationBean registrationBean = new ServletRegistrationBean();
    registrationBean.setServlet(new StatViewServlet());
    registrationBean.addUrlMappings(config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*");
    if (config.getAllow() != null) {
        registrationBean.addInitParameter("allow", config.getAllow());
    } else {
        registrationBean.addInitParameter("allow", DEFAULT_ALLOW_IP);
    }
    if (config.getDeny() != null) {
        registrationBean.addInitParameter("deny", config.getDeny());
    }
    if (config.getLoginUsername() != null) {
        registrationBean.addInitParameter("loginUsername", config.getLoginUsername());
    }
    if (config.getLoginPassword() != null) {
        registrationBean.addInitParameter("loginPassword", config.getLoginPassword());
    }
    if (config.getResetEnable() != null) {
        registrationBean.addInitParameter("resetEnable", config.getResetEnable());
    }
    return registrationBean;
}
Also used : DruidStatProperties(com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) StatViewServlet(com.alibaba.druid.support.http.StatViewServlet) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DruidStatProperties

use of com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties in project druid by alibaba.

the class DruidWebStatFilterConfiguration method webStatFilterRegistrationBean.

@Bean
public FilterRegistrationBean webStatFilterRegistrationBean(DruidStatProperties properties) {
    DruidStatProperties.WebStatFilter config = properties.getWebStatFilter();
    FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    WebStatFilter filter = new WebStatFilter();
    registrationBean.setFilter(filter);
    registrationBean.addUrlPatterns(config.getUrlPattern() != null ? config.getUrlPattern() : "/*");
    registrationBean.addInitParameter("exclusions", config.getExclusions() != null ? config.getExclusions() : "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
    if (config.getSessionStatEnable() != null) {
        registrationBean.addInitParameter("sessionStatEnable", config.getSessionStatEnable());
    }
    if (config.getSessionStatMaxCount() != null) {
        registrationBean.addInitParameter("sessionStatMaxCount", config.getSessionStatMaxCount());
    }
    if (config.getPrincipalSessionName() != null) {
        registrationBean.addInitParameter("principalSessionName", config.getPrincipalSessionName());
    }
    if (config.getPrincipalCookieName() != null) {
        registrationBean.addInitParameter("principalCookieName", config.getPrincipalCookieName());
    }
    if (config.getProfileEnable() != null) {
        registrationBean.addInitParameter("profileEnable", config.getProfileEnable());
    }
    return registrationBean;
}
Also used : DruidStatProperties(com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties) WebStatFilter(com.alibaba.druid.support.http.WebStatFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DruidStatProperties (com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties)2 Bean (org.springframework.context.annotation.Bean)2 StatViewServlet (com.alibaba.druid.support.http.StatViewServlet)1 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)1 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1