| 1 | |
package com.ctrip.apollo.common.controller; |
| 2 | |
|
| 3 | |
import javax.servlet.DispatcherType; |
| 4 | |
|
| 5 | |
import org.springframework.boot.context.embedded.FilterRegistrationBean; |
| 6 | |
import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; |
| 7 | |
import org.springframework.context.annotation.Bean; |
| 8 | |
import org.springframework.context.annotation.Configuration; |
| 9 | |
|
| 10 | |
import com.dianping.cat.servlet.CatFilter; |
| 11 | |
import com.dianping.cat.servlet.CatListener; |
| 12 | |
|
| 13 | |
@Configuration |
| 14 | 0 | public class CatConfig { |
| 15 | |
|
| 16 | |
@Bean |
| 17 | |
public FilterRegistrationBean catFilter() { |
| 18 | 0 | FilterRegistrationBean bean = new FilterRegistrationBean(); |
| 19 | 0 | bean.setFilter(new CatFilter()); |
| 20 | 0 | bean.setName("cat-filter"); |
| 21 | 0 | bean.addUrlPatterns("/*"); |
| 22 | 0 | bean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD); |
| 23 | 0 | return bean; |
| 24 | |
} |
| 25 | |
|
| 26 | |
@Bean |
| 27 | |
public ServletListenerRegistrationBean<CatListener> catListener() { |
| 28 | 0 | ServletListenerRegistrationBean<CatListener> bean = |
| 29 | |
new ServletListenerRegistrationBean<CatListener>(new CatListener()); |
| 30 | 0 | bean.setName("cat-listener"); |
| 31 | 0 | return bean; |
| 32 | |
} |
| 33 | |
} |