@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface PayloadInterception
String
or Payload
.
You can get information from the intercepted method like parameter values, the instance or the return value by declaring parameters annotated with
the annotations from the com.jprofiler.api.probe.injected.parameter package. You can also declare a parameter of type ProbeContext
to
open or close control objects or create payloads with enhanced functionality.
If you return a Payload
to specify control objects or custom event types you must declare a parameter of type ProbeContext
and create the returned object with
ProbeContext.createPayload(String, Object, Enum)
or ProbeContext.createPayloadWithDeferredName(Object, Enum)
. The invokeOn()
argument must be set
to InvocationType.ENTER
in that case.
If you create a Payload
with a deferred name because the payload name cannot be determined at method entry, you must declare a method directly below the current interception method,
annotate it with AdditionalInterception
where AdditionalInterception.value()
is set to InvocationType.EXIT
and return a String
from that method.
If you don't want to create a payload for the current invocation, the probe method can return null
.
Modifier and Type | Required Element and Description |
---|---|
InvocationType |
invokeOn
The point at which the annotated probe method is invoked.
|
MethodSpec |
method
Specifies the method that should be intercepted.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
exceptionPayloads
If payloads should also be recorded if the method throws an exception.
|
boolean |
reentrant
Indicates if your interception is reentrant.
|
public abstract InvocationType invokeOn
public abstract MethodSpec method
public abstract boolean reentrant
false
, the probe method will not be called for recursive invocations of the intercepted method.
If true
, the payload name (and the other information in Payload
) returned by the subsequent inner calls will be used, but timing and call tree location will be used from the outermost call. You can use
ProbeContext.restartTiming()
and ProbeContext.restartTimingAndLocation()
to customize this behavior. If you want to retain the name from outer calls you can use ProbeContext.getOuterPayload()
.
public abstract boolean exceptionPayloads
invokeOn()
is set to InvocationType.EXCEPTION
or InvocationType.EXIT
,
JProfiler will always record payloads for exceptional exits.