2
2
3
3
import dev .aikido .agent .wrappers .Wrapper ;
4
4
import dev .aikido .agent_api .collectors .WebRequestCollector ;
5
- import dev .aikido .agent_api .collectors .WebResponseCollector ;
6
5
import dev .aikido .agent_api .context .Context ;
7
6
import dev .aikido .agent_api .context .ContextObject ;
8
7
import dev .aikido .agent_api .context .JavalinContextObject ;
9
8
import io .javalin .http .servlet .JavalinServletContext ;
10
- import jakarta .servlet .http .HttpServletResponse ;
11
9
import net .bytebuddy .asm .Advice ;
12
10
import net .bytebuddy .description .method .MethodDescription ;
13
11
import net .bytebuddy .description .type .TypeDescription ;
14
12
import net .bytebuddy .matcher .*;
15
13
16
- import java .lang .reflect .Executable ;
17
-
18
14
import static net .bytebuddy .implementation .bytecode .assign .Assigner .Typing .DYNAMIC ;
19
15
import static net .bytebuddy .matcher .ElementMatchers .*;
20
16
@@ -35,13 +31,11 @@ public ElementMatcher<? super TypeDescription> getTypeMatcher() {
35
31
}
36
32
public class JavalinAdvice {
37
33
@ Advice .OnMethodEnter (suppress = Throwable .class )
38
- public static JavalinServletContext before (
39
- @ Advice .This (typing = DYNAMIC , optional = true ) Object target ,
40
- @ Advice .Origin Executable method ,
34
+ public static void before (
41
35
@ Advice .Argument (value = 0 , typing = DYNAMIC , optional = true ) JavalinServletContext ctx
42
- ) {
36
+ ) {
43
37
if (Context .get () != null ) {
44
- return ctx ; // Do not extract if context already exists.
38
+ return ; // Do not extract if context already exists.
45
39
}
46
40
// Create a context object :
47
41
ContextObject context = new JavalinContextObject (
@@ -56,14 +50,6 @@ public static JavalinServletContext before(
56
50
ctx .status (response .status ());
57
51
ctx .skipRemainingHandlers ();
58
52
}
59
-
60
- return ctx ;
61
- }
62
- @ Advice .OnMethodExit (suppress = Throwable .class , onThrowable = Throwable .class )
63
- public static void after (
64
- @ Advice .Enter (typing = DYNAMIC ) JavalinServletContext ctx
65
- ) {
66
- WebResponseCollector .report (ctx .statusCode ());
67
53
}
68
54
}
69
55
0 commit comments