|
JProfiler API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jprofiler.api.agent.interceptor.Interceptor
public abstract class Interceptor
Base class for deriving a concrete interceptor. An interceptor can inject itself into arbitrary methods and monitor entry, exit and exception exit as well as parameters and return value. Based on that information it can create "payload" that can be added to the current call stack together with a payload timing. Payload statistics is displayed in the "Call Tree" view and each payload type adds a new hot spot type to the "Hot Spots" view.
The functionality offered by interceptors is similar to that of the built-in J2EE service call measurements (JDBC, JMS and JNDI).
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.
The implementsInterface(java.lang.Object, java.lang.String)
is useful for checking interface-based hierarchies.
Important:Interceptors cannot intercept methods in the following classes:
Interceptors are added to the profiled process with an InterceptorProvider
.
InterceptorProvider
Constructor Summary | |
---|---|
Interceptor()
|
Method Summary | |
---|---|
protected PayloadInfo |
createPayloadInfo(java.lang.String description)
Creates a payload info object for this interceptor. |
protected PayloadInfo |
createPayloadInfo(java.lang.String description,
java.lang.Object memento)
Creates a payload info object for this interceptor with a memento object. |
abstract java.lang.String |
getInterceptionDescription()
A description for this interceptor. |
abstract InterceptionMethod[] |
getInterceptionMethods()
Defines the methods that should be intercepted by this interceptor. |
protected boolean |
implementsInterface(java.lang.Object object,
java.lang.String interfaceName)
Helper method to check whether the class of an object implements an interface. |
abstract void |
interceptionEnter(java.lang.Object object,
java.lang.String declaringClassName,
java.lang.String methodName,
java.lang.String methodSignature,
java.lang.Object[] arguments)
Called when an intercepted method is entered. |
abstract void |
interceptionExceptionExit(java.lang.Object object,
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. |
abstract void |
interceptionExit(java.lang.Object object,
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. |
protected static boolean |
isCpuRecording()
Determines if CPU data is being recorded by the profiling agent. |
protected static boolean |
isTargetMethod(java.lang.String actualMethodName,
java.lang.String actualMethodSignature,
java.lang.String targetMethodName,
java.lang.String targetMethodSignature)
Helper method to check if a method name and signature are equivalent with target values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Interceptor()
Method Detail |
---|
public abstract void interceptionEnter(java.lang.Object object, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Object[] arguments)
interceptionExceptionExit(Object, String, String, String, Throwable)
method.
If you perform wildcard interception based on method names only, you should check if the object has the expected class hierarchy.
object
- the object on which the intercepted method was calleddeclaringClassName
- the class where the intercepted method has been declaredmethodName
- the name of the intercepted methodmethodSignature
- 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)createPayloadInfo(String, Object)
public abstract void interceptionExit(java.lang.Object object, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Object returnValue)
PayloadInfo.calculateTime()
on the payload info that you created in interceptionEnter(java.lang.Object, java.lang.String, java.lang.String, java.lang.String, java.lang.Object[])
.
object
- the object on which the intercepted method was calleddeclaringClassName
- the class where the intercepted method has been declaredmethodName
- the name of the intercepted methodmethodSignature
- 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.public abstract void interceptionExceptionExit(java.lang.Object object, java.lang.String declaringClassName, java.lang.String methodName, java.lang.String methodSignature, java.lang.Throwable throwable)
object
- the object on which the intercepted method was calleddeclaringClassName
- the class where the intercepted method has been declaredmethodName
- the name of the intercepted methodmethodSignature
- 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 methodpublic abstract InterceptionMethod[] getInterceptionMethods()
InterceptionMethod
for more information.
When the interceptor is used within a trigger, this method is ignored and may return null.
public abstract java.lang.String getInterceptionDescription()
protected PayloadInfo createPayloadInfo(java.lang.String description)
PayloadInfo
for more information.
description
- the payload description
protected PayloadInfo createPayloadInfo(java.lang.String description, java.lang.Object memento)
PayloadInfo
for more information.
description
- the payload descriptionmemento
- a memento object for information that you need in order to analyze the payload info in a different context.
protected final boolean implementsInterface(java.lang.Object object, java.lang.String interfaceName)
object
- the object whose class should be checkedinterfaceName
- the name of the interface that should be checked
protected static boolean isTargetMethod(java.lang.String actualMethodName, java.lang.String actualMethodSignature, java.lang.String targetMethodName, java.lang.String targetMethodSignature)
actualMethodName
- the method name as passed to the interceptor methodsactualMethodSignature
- the method signature as passed to the interceptor methodstargetMethodName
- the method name against which you are testingtargetMethodSignature
- the method signature against which you are testing in JVM format. See InterceptionMethod
for more information on that format.
protected static boolean isCpuRecording()
|
JProfiler API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |