29
29
import com .navercorp .pinpoint .bootstrap .plugin .ProfilerPluginSetupContext ;
30
30
import com .navercorp .pinpoint .plugin .spring .web .interceptor .ExposePathWithinMappingInterceptor ;
31
31
import com .navercorp .pinpoint .plugin .spring .web .interceptor .InvocableHandlerMethodInvokeForRequestMethodInterceptor ;
32
- import com .navercorp .pinpoint .plugin .spring .web .interceptor .LookupHandlerMethodInterceptor ;
33
- import com .navercorp .pinpoint .plugin .spring .web .interceptor .ProcessRequestInterceptor ;
32
+ import com .navercorp .pinpoint .plugin .spring .web .javax . interceptor .LookupHandlerMethodInterceptor ;
33
+ import com .navercorp .pinpoint .plugin .spring .web .javax . interceptor .ProcessRequestInterceptor ;
34
34
35
35
import java .security .ProtectionDomain ;
36
36
@@ -64,6 +64,7 @@ public void setup(ProfilerPluginSetupContext context) {
64
64
}
65
65
66
66
}
67
+
67
68
public static class AbstractHandlerMethodMappingTransform implements TransformCallback {
68
69
@ Override
69
70
public byte [] doInTransform (Instrumentor instrumentor , ClassLoader classLoader , String className , Class <?> classBeingRedefined , ProtectionDomain protectionDomain , byte [] classfileBuffer ) throws InstrumentException {
@@ -74,6 +75,13 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader,
74
75
if (lookupHandlerMethod != null ) {
75
76
lookupHandlerMethod .addInterceptor (LookupHandlerMethodInterceptor .class );
76
77
}
78
+
79
+ // Spring 6
80
+ final InstrumentMethod lookupHandlerMethodJakarta = target .getDeclaredMethod ("lookupHandlerMethod" , "java.lang.String" , "jakarta.servlet.http.HttpServletRequest" );
81
+ if (lookupHandlerMethodJakarta != null ) {
82
+ lookupHandlerMethodJakarta .addInterceptor (com .navercorp .pinpoint .plugin .spring .web .jakarta .interceptor .LookupHandlerMethodInterceptor .class );
83
+ }
84
+
77
85
return target .toBytecode ();
78
86
}
79
87
}
@@ -88,6 +96,13 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader,
88
96
if (exposePathWithinMapping != null ) {
89
97
exposePathWithinMapping .addInterceptor (ExposePathWithinMappingInterceptor .class );
90
98
}
99
+
100
+ // Spring 6
101
+ final InstrumentMethod exposePathWithinMappingJakarta = target .getDeclaredMethod ("exposePathWithinMapping" , "java.lang.String" , "java.lang.String" , "jakarta.servlet.http.HttpServletRequest" );
102
+ if (exposePathWithinMappingJakarta != null ) {
103
+ exposePathWithinMappingJakarta .addInterceptor (ExposePathWithinMappingInterceptor .class );
104
+ }
105
+
91
106
return target .toBytecode ();
92
107
}
93
108
}
@@ -104,15 +119,40 @@ public FrameworkServletTransform(Boolean uriStatEnable, Boolean uriStatUseUserIn
104
119
105
120
@ Override
106
121
public byte [] doInTransform (Instrumentor instrumentor , ClassLoader loader , String className , Class <?> classBeingRedefined , ProtectionDomain protectionDomain , byte [] classfileBuffer ) throws InstrumentException {
107
- InstrumentClass target = instrumentor .getInstrumentClass (loader , className , classfileBuffer );
108
- InstrumentMethod doGet = target .getDeclaredMethod ("doGet" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
109
- doGet .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
110
- InstrumentMethod doPost = target .getDeclaredMethod ("doPost" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
111
- doPost .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
122
+ final InstrumentClass target = instrumentor .getInstrumentClass (loader , className , classfileBuffer );
123
+
124
+ final InstrumentMethod doGet = target .getDeclaredMethod ("doGet" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
125
+ final InstrumentMethod doPost = target .getDeclaredMethod ("doPost" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
126
+ if (doGet != null ) {
127
+ doGet .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
128
+ }
129
+ if (doPost != null ) {
130
+ doPost .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
131
+ }
132
+
133
+ // Spring 6
134
+ final InstrumentMethod doGetJakarta = target .getDeclaredMethod ("doGet" , "jakarta.servlet.http.HttpServletRequest" , "jakarta.servlet.http.HttpServletResponse" );
135
+ final InstrumentMethod doPostJakarta = target .getDeclaredMethod ("doPost" , "jakarta.servlet.http.HttpServletRequest" , "jakarta.servlet.http.HttpServletResponse" );
136
+ if (doGetJakarta != null ) {
137
+ doGetJakarta .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
138
+ }
139
+ if (doPostJakarta != null ) {
140
+ doPostJakarta .addInterceptor (BasicMethodInterceptor .class , va (SpringWebMvcConstants .SPRING_MVC ));
141
+ }
142
+
112
143
if (this .uriStatEnable ) {
113
- InstrumentMethod processRequest = target .getDeclaredMethod ("processRequest" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
114
- processRequest .addInterceptor (ProcessRequestInterceptor .class , va (this .uriStatUseUserInput ));
144
+ final InstrumentMethod processRequest = target .getDeclaredMethod ("processRequest" , "javax.servlet.http.HttpServletRequest" , "javax.servlet.http.HttpServletResponse" );
145
+ if (processRequest != null ) {
146
+ processRequest .addInterceptor (ProcessRequestInterceptor .class , va (this .uriStatUseUserInput ));
147
+ }
148
+
149
+ // Spring 6
150
+ final InstrumentMethod processRequestJakarta = target .getDeclaredMethod ("processRequest" , "jakarta.servlet.http.HttpServletRequest" , "jakarta.servlet.http.HttpServletResponse" );
151
+ if (processRequestJakarta != null ) {
152
+ processRequestJakarta .addInterceptor (com .navercorp .pinpoint .plugin .spring .web .jakarta .interceptor .ProcessRequestInterceptor .class , va (this .uriStatUseUserInput ));
153
+ }
115
154
}
155
+
116
156
return target .toBytecode ();
117
157
}
118
158
}
0 commit comments