All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.vality.woody.api.proxy.tracer.EventTracer Maven / Gradle / Ivy

There is a newer version: 2.0.8
Show newest version
package dev.vality.woody.api.proxy.tracer;


import dev.vality.woody.api.proxy.InstanceMethodCaller;

public class EventTracer implements MethodCallTracer {

    private final Runnable beforeCallListener;
    private final Runnable afterCallListener;
    private final Runnable errListener;

    public EventTracer() {
        this(null, null, null);
    }

    public EventTracer(Runnable beforeCallListener, Runnable afterCallListener, Runnable errListener) {
        this.beforeCallListener = beforeCallListener != null ? beforeCallListener : () -> {
        };
        this.afterCallListener = afterCallListener != null ? afterCallListener : () -> {
        };
        this.errListener = errListener != null ? errListener : () -> {
        };
    }

    @Override
    public void beforeCall(Object[] args, InstanceMethodCaller caller) {
        beforeCallListener.run();
    }

    @Override
    public void afterCall(Object[] args, InstanceMethodCaller caller, Object result) {
        afterCallListener.run();
    }

    @Override
    public void callError(Object[] args, InstanceMethodCaller caller, Throwable error) {
        errListener.run();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy