因为要和老系统集成zipkin,意外的发现老系统使用的httpClient来发送信息。zipkin的官方demo可都是retstTemplate啊!有的搞头。
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/spring-webmvc-servlet.xml,/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
static {
javaVersion = System.getProperty("java.version");
// version String should look like "1.4.2_10"
if (javaVersion.indexOf("1.7.") != -1) {
majorJavaVersion = JAVA_17;
6 }
else if (javaVersion.indexOf("1.6.") != -1) {
majorJavaVersion = JAVA_16;
}
else if (javaVersion.indexOf("1.5.") != -1) {
majorJavaVersion = JAVA_15;
}
else {
// else leave 1.4 as default (it's either 1.4 or unknown)
majorJavaVersion = JAVA_14;
}
}
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
HttpClient httpClient = (HttpClient)wac.getBean("httpClient");
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
new String[] { "applicationContext.xml","spring-webmvc-servlet.xml" });
BeanFactory factory = (BeanFactory) appContext;
HttpClient httpClient = (HttpClient)factory.getBean("httpClient");
//appContext.close(); return httpClient;
下图是brave-hc-client的信息;因为是sr和sc的,是servlet的brave成功捕获。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4AAAAB9CAYAAADz0A0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABkzSURBVHhe7d1LjuQ6doDhXFHDW/AuDBfaLnjmHrgnBlxGzQp31HeQMBDIVcQuYhMxqRXkImTxJR2Shw8pIkOZwZ+ND4gMUSRFHR6JlXW7Xr59+zZ9//59+vHjBwAAAADgibEBBAAAAIBBsAEEAAAAgEGwAQQAAACAQbABBAAAAIBBsAEEAAAAgEGwAQQAAACAQbABBAAAAIBBsAEEAAAAgEGwAQQAAACAQbABBAAAAIBBsAEEAAAAgEG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/L7ehyPocTD5ny1hdKf9l0UK1vzdau+Hnuyfpk2/lQyX1Ye39qYynMws/NuSjz3+/KAxo2xdR/Ccdtv1GeqVt8ck7kifG6NuzVGbe4N2QeeySfYAJqgqwWXsrhTjfaWRa6UtV2/eHwpJ7TSeNziWkqSYM06qyfJrefX67eupzqe5CHVN3+SkmgySVJJH4z2Z5HAcYB7xXorVoNCf/YhtZao7TRu0rhKYjFpqhGjOFp6v/LYifPcXEHc+1L8zmzcaMd2tpe4bdxxzFq2QZkP5fnzufwzEAcoxEMlX/U8S83p+rO5FH9pLKVxcO98HfeXjnX7+GP55sjndPnPF0Rj0tuNb4OZE2Vd7coDmo416/typWOtFuv7+bDjkZ+N2rjbY1ziU86/u6FJDOAZHLMBHNG8mK9qUgQAAEC+qcGRyht6fHVsAB/kdLmS0AAAACry3wLiEOa3kPz272mxAQQAAMAn0ffXRfGR+E3ss2MDCAAAAACDYAMIAAAAAINgAwgAAAAAg2ADCAAAAACDYAMIAAAAAINgAwgAAAAAg2ADCAAAAACDYAMIAAAAAINgAwgAAAAAg2ADCAAAAACDYAMIAAAAAINgAwgAAAAAg2ADCAAAAACDeHl9fZ3e3t7UgwAAAACA58EGEAAAAAAG8fIv3/46/fXf/0M9CAAAAAB4HmwAAQAAAGAIP6b/B+9Xf2NFoGwMAAAAAElFTkSuQmCCAA==" alt="" width="722" height="100" />
这是因为web.xml里面的配置内容是tomcat要处理的内容,和框架无关(init-param里面定义的细节内容除外),比如servlet,filter等这些都是被tomcat使用;所以filter其实是被tomcat执行,和spring无关,于是servlet可以被DelegateFilter成功处理;但是到applicationContext.xml之类文件的处理(在web.xml文件<servlet>节点的configLocation中定义的配置文件路径)就是各个框架的servlet有针对性的处理,形成了差异化。或者讲,web.xml里面定义的都是全局性的东西,还没有到分context(上下文)的阶段;到了后面针对bean的处理就是只能是针对具体框架了。