org.linkedin.util-core/src/main/java/org/linkedin/util/reflect/ReflectUtils.java
public static <T> T executeWithClassLoader(ClassLoader classLoader,
                                             Callable<T> callable) throws Exception
  {
    ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
    try
    {
      Thread.currentThread().setContextClassLoader(classLoader);
      return callable.call();
    }
    finally
    {
      Thread.currentThread().setContextClassLoader(previousClassLoader);
    }
  }
public static <T> T executeWithClassLoader(ClassLoader classLoader,
                                             Callable<T> callable) throws Exception
  {
    ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
    try
    {
      Thread.currentThread().setContextClassLoader(classLoader);
      return callable.call();
    }
    finally
    {
      Thread.currentThread().setContextClassLoader(previousClassLoader);
    }
  }
public static < T > T executeWithClassLoader ( ClassLoader classLoader , Callable < T > callable ) throws Exception { ClassLoader previousClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( classLoader ) ; return callable . call ( ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( previousClassLoader ) ; } }
Execute the call within the given class loader... handle setting / reverting to
previous class loader in a safe manner.

@param classLoader the class loader to set for the duration of the call
@param callable the callable to execute within the context of the provided class loader
@return the result of the call
@throws Exception whatever callable throws
Execute the call within the given class loader ... handle setting / reverting to previous class loader in a safe manner .