## JProfiler API documentation

## com.jprofiler.api.agent.probe
Interface InterceptorProbe

All Superinterfaces:
  Probe

    public interface InterceptorProbe

extends Probe

Base class for deriving a probe that intercepts methods. An interceptor probe can inject itself into arbitrary methods and monitor entry, exit and exception exit as well as parameters and return value.

Note that implementation classes that are observed by an interceptor are only available if they are in the boot classpath. Since this is usually not the case, you have to check class hierarchies by using the reflection API.

Important:Interceptors cannot intercept methods in the following classes:

- classes that are loaded before the main class is loaded
- the main class and its superclasses

Probes are added to the profiled process with a `ProbeProvider`.

See Also:
  `ProbeProvider`

Method Summary
`InterceptionMethod[]` | `getInterceptionMethods()` Defines the methods that should be intercepted by this interceptor probe.
`void` | `interceptionEnter(InterceptorContext context, java.lang.Object object, java.lang.Class declaringClass, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Object[] arguments)` Called when an intercepted method is entered.
`void` | `interceptionExceptionExit(InterceptorContext context, java.lang.Object object, java.lang.Class declaringClass, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Throwable throwable)` Called when an in intercepted method is exited because an exception is thrown.
`void` | `interceptionExit(InterceptorContext context, java.lang.Object object, java.lang.Class declaringClass, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Object returnValue)` Called when an intercepted method is exited via a regular return call.

Methods inherited from interface com.jprofiler.api.agent.probe.Probe
`getMetaData`

Method Detail

### interceptionEnter

    void interceptionEnter(InterceptorContext context,
                           java.lang.Object object,
                           java.lang.Class declaringClass,
                           java.lang.String declaringClassName,
                           java.lang.String methodName,
                           java.lang.String methodSignature,
                           java.lang.Object[] arguments)
                           throws java.lang.Throwable

  Called when an intercepted method is entered. If you want to add payload information with a time measurement to the current call stack, you should create the payload info in this method and save it in the thread local payload stack offered by the interceptor context with `InterceptorContext.push(PayloadInfo)`. You can retrieve it again with `InterceptorContext.pop()` in the `interceptionExceptionExit(InterceptorContext, Object, Class, String, String, String, Throwable)` method in order to calculate times and to publish it.

  If you perform wildcard interception based on method names only, you should check if the object has the expected class hierarchy.

  Parameters:
    `context` - the context you can use to create payload and probe data
    `object` - the object on which the intercepted method was called
    `declaringClass` - the class object where the intercepted method has been declared. This is `null` on JVMs prior to version 1.6.
    `declaringClassName` - the class where the intercepted method has been declared
    `methodName` - the name of the intercepted method
    `methodSignature` - the signature of the intercepted method in JVM format. See `InterceptionMethod` for more information on that format.
    `arguments` - the arguments that were passed to the intercepted method or an empty array if the method has no arguments. @see #createPayloadInfo(String) @see #createPayloadInfo(String, Object)
  Throws:
    `java.lang.Throwable`

### interceptionExit

    void interceptionExit(InterceptorContext context,
                          java.lang.Object object,
                          java.lang.Class declaringClass,
                          java.lang.String declaringClassName,
                          java.lang.String methodName,
                          java.lang.String methodSignature,
                          java.lang.Object returnValue)
                          throws java.lang.Throwable

  Called when an intercepted method is exited via a regular return call. If you want to add payload information with a time measurement to the current call stack, you should call `PayloadInfo.calculateTime()` on the payload info that you created in `interceptionEnter(InterceptorContext, Object, Class, String, String, String, Object[])`.

  Parameters:
    `context` - the context you can use to create payload and probe data
    `object` - the object on which the intercepted method was called
    `declaringClass` - the class object where the intercepted method has been declared. This is `null` on JVMs prior to version 1.6.
    `declaringClassName` - the class where the intercepted method has been declared
    `methodName` - the name of the intercepted method
    `methodSignature` - the signature of the intercepted method in JVM format. See `InterceptionMethod` for more information on that format.
    `returnValue` - the value that was returned by the intercepted method or `null` if the return type of the method is `void`.
  Throws:
    `java.lang.Throwable`

### interceptionExceptionExit

    void interceptionExceptionExit(InterceptorContext context,
                                   java.lang.Object object,
                                   java.lang.Class declaringClass,
                                   java.lang.String declaringClassName,
                                   java.lang.String methodName,
                                   java.lang.String methodSignature,
                                   java.lang.Throwable throwable)
                                   throws java.lang.Throwable

  Called when an in intercepted method is exited because an exception is thrown.

  Parameters:
    `context` - the context you can use to create payload and probe data
    `object` - the object on which the intercepted method was called
    `declaringClass` - the class object where the intercepted method has been declared. This is `null` on JVMs prior to version 1.6.
    `declaringClassName` - the class where the intercepted method has been declared
    `methodName` - the name of the intercepted method
    `methodSignature` - the signature of the intercepted method in JVM format. See `InterceptionMethod` for more information on that format.
    `throwable` - the exception that was thrown in the intercepted method
  Throws:
    `java.lang.Throwable`

### getInterceptionMethods

    InterceptionMethod[] getInterceptionMethods()

  Defines the methods that should be intercepted by this interceptor probe. See `InterceptionMethod` for more information.

  Returns:
    the intercepted methods