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

io.mongock.driver.api.lock.guard.proxy.LockGuardMethodHandler Maven / Gradle / Ivy

The newest version!
package io.mongock.driver.api.lock.guard.proxy;

import io.mongock.driver.api.lock.LockManager;
import java.lang.reflect.InvocationTargetException;
import javassist.util.proxy.MethodHandler;

import java.lang.reflect.Method;
import java.util.Set;

public class LockGuardMethodHandler implements MethodHandler {

  private final LockGuardProxy lockGuardProxy;

  public LockGuardMethodHandler(T implementation, LockManager lockManager, LockGuardProxyFactory proxyFactory, Set nonGuardedMethods) {
    this.lockGuardProxy = new LockGuardProxy<>(implementation, lockManager, proxyFactory, nonGuardedMethods);
  }

  public LockGuardProxy getLockGuardProxy() {
    return lockGuardProxy;
  }

  @Override
  public Object invoke(Object proxy, Method method, Method method1, Object[] methodArgs) throws Throwable {
    try {
      return lockGuardProxy.invoke(proxy, method, methodArgs);
    } catch (InvocationTargetException ex) {
      if (ex.getTargetException() != null) {
        throw ex.getTargetException();
      }
      throw ex;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy