final MethodInvocation copy = (MethodInvocation) invocation.copy();
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
java.util.concurrent.Future future = executor.submit(new Callable()
{
public Object call() throws Exception
{
try
{
Thread.currentThread().setContextClassLoader(cl);
return copy.invokeNext();
}
catch (Throwable throwable)
{
if (throwable instanceof Exception)
{
throw ((Exception) throwable);
}
else
throw new Exception(throwable);
}
}
});
return new FutureImplJavaUtilConcurrent(future);