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

io.jexxa.core.FluentMonitor Maven / Gradle / Ivy

The newest version!
package io.jexxa.core;

import io.jexxa.adapterapi.invocation.InvocationManager;
import io.jexxa.adapterapi.invocation.monitor.AfterMonitor;
import io.jexxa.adapterapi.invocation.monitor.AroundMonitor;
import io.jexxa.adapterapi.invocation.monitor.BeforeMonitor;

import java.util.Objects;

@SuppressWarnings({"unused"})
public final class FluentMonitor
{
    private final Object targetObject;
    private final JexxaMain jexxaMain;

    FluentMonitor(JexxaMain jexxaMain, Object targetObject )
    {
        this.targetObject = Objects.requireNonNull( targetObject );
        this.jexxaMain = Objects.requireNonNull( jexxaMain );
    }

    public JexxaMain with(BeforeMonitor monitor)
    {
        monitor.setObservedObject(targetObject);
        InvocationManager.getRootInterceptor(targetObject).registerBefore(monitor);
        return jexxaMain.registerHealthCheck(monitor);
    }

    public JexxaMain with(AfterMonitor monitor)
    {
        InvocationManager.getRootInterceptor(targetObject).registerAfter(monitor);
        return jexxaMain.registerHealthCheck(monitor);
    }

    public JexxaMain with(AroundMonitor monitor)
    {
        InvocationManager.getRootInterceptor(targetObject).registerAround(monitor);
        return jexxaMain.registerHealthCheck(monitor);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy