Class ProxyUtil

java.lang.Object
com.atlassian.crowd.common.util.ProxyUtil

public class ProxyUtil extends Object
Utility class simplifying creation of proxy objects.
  • Method Details

    • runWithContextClassLoader

      public static <T> T runWithContextClassLoader(ClassLoader classLoader, T service)
      Creates a proxy that will call service with provided classLoader. After the call original context class loader will be restored.
      See Also:
    • runInTransaction

      public static <T> T runInTransaction(T service, Function<Supplier<?>,?> transactionalRunner)
    • cached

      public static <T> T cached(Map<Object,org.apache.commons.lang3.tuple.Pair<Object,Throwable>> cache, T original)
    • newProxy

      public static <T> T newProxy(T service, InvocationHandler handler)
      Type Parameters:
      T - the target interface
      Parameters:
      service - to be proxied
      handler - that intercepts method invocations
      Returns:
      a proxy of the target interface
      Throws:
      ClassCastException - if the service does not have any interfaces, or T is not an interface