Thread currentThread = Thread.currentThread();
ClassLoader existingClassLoader = currentThread.getContextClassLoader();
try {
if (setContextClassLoader) {
ServiceRegistryReference serviceReference = targetSource.getServiceRegistryReference();
//this will only not be null if the service is removed directly after the hasTargetSource() call
if (serviceReference != null) {
currentThread.setContextClassLoader(serviceReference.getBeanClassLoader());
}
}
return invocation.proceed();
} finally {