Annotation Interface PayloadInterception


@Retention(RUNTIME) @Target(METHOD) public @interface PayloadInterception
Declares an interception that creates a payload. The annotated probe method must be public and static and return 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.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The point at which the annotated probe method is invoked.
    Specifies the method that should be intercepted.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    If payloads should also be recorded if the method throws an exception.
    boolean
    Indicates if your interception is reentrant.
  • Element Details

    • invokeOn

      InvocationType invokeOn
      The point at which the annotated probe method is invoked.
      Returns:
      the invocation type
    • method

      MethodSpec method
      Specifies the method that should be intercepted.
      Returns:
      a method specification
    • reentrant

      boolean reentrant
      Indicates if your interception is reentrant. If 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().

      Returns:
      if your probe method should be called for recursive invocations
      Default:
      false
    • exceptionPayloads

      boolean exceptionPayloads
      If payloads should also be recorded if the method throws an exception. If invokeOn() is set to InvocationType.EXCEPTION or InvocationType.EXIT, JProfiler will always record payloads for exceptional exits.
      Returns:
      if payloads should be recorded for exceptional exits
      Default:
      false