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

dev.vality.woody.api.proxy.tracer.CompositeTracer 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;

import java.util.Arrays;
import java.util.Collection;

public class CompositeTracer implements MethodCallTracer {
    private final MethodCallTracer[] tracers;

    public CompositeTracer(MethodCallTracer... callTracers) {
        this(Arrays.asList(callTracers));
    }

    public CompositeTracer(Collection tracers) {
        this.tracers = tracers.toArray(new MethodCallTracer[0]);
    }

    @Override
    public void beforeCall(Object[] args, InstanceMethodCaller caller) throws Exception {
        for (int i = 0; i < tracers.length; ++i) {
            tracers[i].beforeCall(args, caller);
        }
    }

    @Override
    public void afterCall(Object[] args, InstanceMethodCaller caller, Object result) throws Exception {
        for (int i = 0; i < tracers.length; ++i) {
            tracers[i].afterCall(args, caller, result);
        }
    }

    @Override
    public void callError(Object[] args, InstanceMethodCaller caller, Throwable error) throws Exception {
        for (int i = 0; i < tracers.length; ++i) {
            tracers[i].callError(args, caller, error);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy