use of com.alibaba.druid.support.http.WebStatFilter in project benchmark by seelunzi.
the class DruidConfiguration method filterRegistrationBean.
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
return filterRegistrationBean;
}
use of com.alibaba.druid.support.http.WebStatFilter in project flybiner-sso by youyouxi.
the class DruidConfig method filterRegistrationBean.
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
filterRegistrationBean.addInitParameter("profileEnable", "true");
filterRegistrationBean.addInitParameter("principalCookieName", "USER_COOKIE");
filterRegistrationBean.addInitParameter("principalSessionName", "USER_SESSION");
return filterRegistrationBean;
}
use of com.alibaba.druid.support.http.WebStatFilter in project neweagle-api by apgzs.
the class DruidConfiguration method filterRegistrationBean.
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
return filterRegistrationBean;
}
use of com.alibaba.druid.support.http.WebStatFilter in project druid by alibaba.
the class DruidStatServiceTest method test_statService_getWebURIList.
public void test_statService_getWebURIList() throws Exception {
String uri = "/";
MockServletContext servletContext = new MockServletContext();
MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
WebStatFilter filter = new WebStatFilter();
filter.init(filterConfig);
// first request test
MockHttpServletRequest request = new MockHttpServletRequest("GET", uri);
MockHttpServletResponse response = new MockHttpServletResponse();
MockFilterChain chain = new MockFilterChain();
filter.doFilter(request, response, chain);
String result = DruidStatService.getInstance().service("/weburi.json");
Map<String, Object> resultMap = (Map<String, Object>) JSONUtils.parse(result);
List<Map<String, Object>> webURIList = (List<Map<String, Object>>) resultMap.get("Content");
assertThat(webURIList.size(), equalTo(1));
Map<String, Object> webURI = webURIList.get(0);
assertThat((String) webURI.get("URI"), equalTo(uri));
assertThat((Integer) webURI.get("RequestCount"), equalTo(1));
// second request test
MockHttpServletRequest request2 = new MockHttpServletRequest("GET", uri);
MockHttpServletResponse response2 = new MockHttpServletResponse();
MockFilterChain chain2 = new MockFilterChain();
filter.doFilter(request2, response2, chain2);
result = DruidStatService.getInstance().service("/weburi.json");
resultMap = (Map<String, Object>) JSONUtils.parse(result);
webURIList = (List<Map<String, Object>>) resultMap.get("Content");
assertThat(webURIList.size(), equalTo(1));
webURI = webURIList.get(0);
assertThat((String) webURI.get("URI"), equalTo(uri));
assertThat((Integer) webURI.get("RequestCount"), equalTo(2));
filter.destroy();
}
use of com.alibaba.druid.support.http.WebStatFilter 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;
}
Aggregations