Interface ProbeContext


public interface ProbeContext
An interface for enhanced probe functionality. In methods annotated with Interception, PayloadInterception, SplitInterception and AdditionalInterception, you can declare a parameter of this type in any position in order to get an instance of this class.
  • Method Details

    • openControlObject

      void openControlObject(Object controlObject, String name)
      Records an open event for a control object and assigns a name to it. The control object will be displayed in the control objects view and the timeline. You must set Probe.controlObjects() to true to enable control object recording as a capability for the probe.

      If you don't use this method and a previously unknown control object is used in a createPayload(String, Object, Enum) call and you have annotated a method in your probe class with ControlObjectName, that method will be called create a name for the new control object. No open event will be created in the events view in that case.

      Parameters:
      controlObject - the control object
      name - the name of the control object
    • closeControlObject

      void closeControlObject(Object controlObject)
      Closes a control object. If the control object is not currently open, this method has no effect.
      Parameters:
      controlObject - the control object
    • createPayload

      Payload createPayload(String name, Object controlObject, Enum<?> type)

      Creates an enhanced payload object with type and control object info. You can use the created object in

      If you don't want to assign states or control objects, you can just return the name as a String directly.

      Parameters:
      name - the name of the recorded payload. If null, the payload recording will be discarded.
      type - the payload type. Must by an object of your custom enum class registered with Probe.customTypes() or null.
      controlObject - the control object this payload belongs to or null. If control objects should be recorded, you have to set Probe.controlObjects() to true.
      Returns:
      a Payload instance to be returned by your interception method
    • createPayloadWithDeferredName

      Payload createPayloadWithDeferredName(Object controlObject, Enum<?> type)
      Creates an enhanced payload object with type and control object info which name you don't know yet. You can use the created object in a method returning a Payload that is annotated with PayloadInterception and where PayloadInterception.invokeOn() is set to InvocationType.ENTER. If you don't want to assign states or control objects you can just return the name as a String directly.

      To supply the name at a later point, you have to define a method right below the current method, annotate it with AdditionalInterception and return a String.

      If you don't want to assign states or control objects, you can set PayloadInterception.invokeOn() to InvocationType.EXIT and return the name as a String directly.

      Parameters:
      type - the payload type. Must by an object of your custom enum class registered with Probe.customTypes() or null.
      controlObject - the control object this payload belongs to or null. If control objects should be recorded, you have to set Probe.controlObjects() to true.
      Returns:
      a Payload instance to be returned by your interception method
    • getOuterPayload

      Payload getOuterPayload()
      Retrieves the payload information that has been created by an outer interception, either through recursion or by a different intercepted method.

      If your inner interception method is annotated with PayloadInterception, you can return this payload to keep the payload information unchanged. A SplitInterception won't change an outer payload, so this does not apply for nested splits.

      Returns:
      the current payload or null if there is no current payload defined.
    • restartTiming

      void restartTiming()
      If a payload is currently recorded by an outer interception, restart timing.
    • restartTimingAndLocation

      void restartTimingAndLocation()
      If a payload is currently recorded by an outer interception, restart timing and set the call tree to the location of the latest PayloadInterception or the latest SplitInterception with SplitInterception.payloads() set to true.
    • isRecording

      boolean isRecording()
      Returns the recording state of the probe.

      Methods annotated with PayloadInterception are only called when probe recording is turned on. Methods annotated with SplitInterception are called when CPU or allocation recording is turned on. If SplitInterception.payloads() is set to true, they are also called when only probe recording is turned on. Methods annotated with Interception are always called.

      Returns:
      true if your probe is being recorded