use of org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping in project brave by openzipkin.
the class ITTracingHandlerInterceptor method init.
@Override
public void init(ServletContextHandler handler) {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.getBeanFactory().registerSingleton("testController", // the test resource
new TestController(httpTracing));
DefaultAnnotationHandlerMapping mapping = new DefaultAnnotationHandlerMapping();
mapping.setInterceptors(new Object[] { TracingHandlerInterceptor.create(httpTracing) });
mapping.setApplicationContext(wac);
wac.getBeanFactory().registerSingleton(HANDLER_MAPPING_BEAN_NAME, mapping);
wac.getBeanFactory().registerSingleton(HANDLER_ADAPTER_BEAN_NAME, new AnnotationMethodHandlerAdapter());
handler.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
handler.addServlet(new ServletHolder(new DispatcherServlet() {
{
wac.refresh();
setDetectAllHandlerMappings(false);
setDetectAllHandlerAdapters(false);
setPublishEvents(false);
}
@Override
protected WebApplicationContext initWebApplicationContext() throws BeansException {
onRefresh(wac);
return wac;
}
}), "/*");
}
use of org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping in project brave by openzipkin.
the class ITSpanCustomizingHandlerInterceptor method init.
@Override
public void init(ServletContextHandler handler) {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.getBeanFactory().registerSingleton("httpTracing", httpTracing);
wac.getBeanFactory().registerSingleton("testController", // the test resource
new TestController(httpTracing));
DefaultAnnotationHandlerMapping mapping = new DefaultAnnotationHandlerMapping();
mapping.setInterceptors(new Object[] { new SpanCustomizingHandlerInterceptor() });
mapping.setApplicationContext(wac);
wac.getBeanFactory().registerSingleton(HANDLER_MAPPING_BEAN_NAME, mapping);
wac.getBeanFactory().registerSingleton(HANDLER_ADAPTER_BEAN_NAME, new AnnotationMethodHandlerAdapter());
handler.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
handler.addServlet(new ServletHolder(new DispatcherServlet() {
{
wac.refresh();
setDetectAllHandlerMappings(false);
setDetectAllHandlerAdapters(false);
setPublishEvents(false);
}
@Override
protected WebApplicationContext initWebApplicationContext() throws BeansException {
onRefresh(wac);
return wac;
}
}), "/*");
handler.addFilter(DelegatingTracingFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
}
Aggregations