added unwrapping of scoped proxy tp unwrapResourceIfNecessary() (SPR-5671)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2336 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
e1d7fd856f
commit
777c40f667
|
|
@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import org.springframework.core.InfrastructureProxy;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.aop.scope.ScopedObject;
|
||||
|
||||
/**
|
||||
* Utility methods for triggering specific {@link TransactionSynchronization}
|
||||
|
|
@ -55,7 +56,13 @@ public abstract class TransactionSynchronizationUtils {
|
|||
*/
|
||||
static Object unwrapResourceIfNecessary(Object resource) {
|
||||
Assert.notNull(resource, "Resource must not be null");
|
||||
return (resource instanceof InfrastructureProxy ? ((InfrastructureProxy) resource).getWrappedObject() : resource);
|
||||
Object resourceRef = resource;
|
||||
if (resource instanceof ScopedObject) {
|
||||
// First unwrap a scoped proxy.
|
||||
resourceRef = ((ScopedObject) resource).getTargetObject();
|
||||
}
|
||||
// Now unwrap infrastructure proxy
|
||||
return (resourceRef instanceof InfrastructureProxy ? ((InfrastructureProxy) resourceRef).getWrappedObject() : resourceRef);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue