Class MethodCallHook.Builder
- java.lang.Object
-
- com.tonic.analysis.instrumentation.hook.MethodCallHook.Builder
-
- Enclosing class:
- MethodCallHook
public static class MethodCallHook.Builder extends Object
Builder forMethodCallHook, defaulting to enabled, priority 100, before-call placement, an unrestricted target and no values passed.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodCallHook.Builderafter(boolean after)Sets whether the hook runs after the call.MethodCallHook.Builderbefore(boolean before)Sets whether the hook runs before the call.MethodCallHookbuild()MethodCallHook.Builderenabled(boolean enabled)Sets whether the hook is applied at all.MethodCallHook.Builderfilters(List<InstrumentationFilter> filters)Replaces the filters deciding which call sites are instrumented.MethodCallHook.BuilderhookDescriptor(HookDescriptor hookDescriptor)Sets the method the instrumentation will call.MethodCallHook.BuilderpassArguments(boolean passArguments)Sets whether the call arguments are passed to the hook as an object array.MethodCallHook.BuilderpassMethodName(boolean passMethodName)Sets whether the intercepted method name is passed to the hook.MethodCallHook.BuilderpassReceiver(boolean passReceiver)Sets whether the call receiver is passed to the hook.MethodCallHook.BuilderpassResult(boolean passResult)Sets whether the call result is passed to the hook; only meaningful for after-hooks.MethodCallHook.Builderpriority(int priority)Sets the ordering weight against other hooks on the same site.MethodCallHook.BuildertargetClass(String targetClass)Restricts interception to calls on one class.MethodCallHook.BuildertargetDescriptor(String targetDescriptor)Restricts interception to one overload.MethodCallHook.BuildertargetMethod(String targetMethod)Restricts interception to one method name.
-
-
-
Method Detail
-
hookDescriptor
public MethodCallHook.Builder hookDescriptor(HookDescriptor hookDescriptor)
Sets the method the instrumentation will call.- Parameters:
hookDescriptor- the hook method descriptor- Returns:
- this builder
-
filters
public MethodCallHook.Builder filters(List<InstrumentationFilter> filters)
Replaces the filters deciding which call sites are instrumented.- Parameters:
filters- the filter list- Returns:
- this builder
-
enabled
public MethodCallHook.Builder enabled(boolean enabled)
Sets whether the hook is applied at all.- Parameters:
enabled- whether the hook is active- Returns:
- this builder
-
priority
public MethodCallHook.Builder priority(int priority)
Sets the ordering weight against other hooks on the same site.- Parameters:
priority- the priority value- Returns:
- this builder
-
targetClass
public MethodCallHook.Builder targetClass(String targetClass)
Restricts interception to calls on one class.- Parameters:
targetClass- internal name of the class, or null for any class- Returns:
- this builder
-
targetMethod
public MethodCallHook.Builder targetMethod(String targetMethod)
Restricts interception to one method name.- Parameters:
targetMethod- the method name, or null for any method- Returns:
- this builder
-
targetDescriptor
public MethodCallHook.Builder targetDescriptor(String targetDescriptor)
Restricts interception to one overload.- Parameters:
targetDescriptor- the method descriptor, or null for any descriptor- Returns:
- this builder
-
before
public MethodCallHook.Builder before(boolean before)
Sets whether the hook runs before the call.- Parameters:
before- whether to hook the call site entry- Returns:
- this builder
-
after
public MethodCallHook.Builder after(boolean after)
Sets whether the hook runs after the call.- Parameters:
after- whether to hook the call site exit- Returns:
- this builder
-
passReceiver
public MethodCallHook.Builder passReceiver(boolean passReceiver)
Sets whether the call receiver is passed to the hook.- Parameters:
passReceiver- whether to pass the receiver- Returns:
- this builder
-
passArguments
public MethodCallHook.Builder passArguments(boolean passArguments)
Sets whether the call arguments are passed to the hook as an object array.- Parameters:
passArguments- whether to pass the arguments- Returns:
- this builder
-
passResult
public MethodCallHook.Builder passResult(boolean passResult)
Sets whether the call result is passed to the hook; only meaningful for after-hooks.- Parameters:
passResult- whether to pass the result- Returns:
- this builder
-
passMethodName
public MethodCallHook.Builder passMethodName(boolean passMethodName)
Sets whether the intercepted method name is passed to the hook.- Parameters:
passMethodName- whether to pass the method name- Returns:
- this builder
-
build
public MethodCallHook build()
- Returns:
- the configured hook
-
-