|
|
|
@ -31,25 +31,12 @@ public final class ProxyUtils {
@@ -31,25 +31,12 @@ public final class ProxyUtils {
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public static <T> T getTargetObject(Object candidate) { |
|
|
|
|
try { |
|
|
|
|
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) { |
|
|
|
|
return (T) ((Advised) candidate).getTargetSource().getTarget(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { |
|
|
|
|
throw new IllegalStateException("Failed to unwrap proxied object", ex); |
|
|
|
|
} |
|
|
|
|
return (T) candidate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public static <T> T getUltimateTargetObject(Object candidate) { |
|
|
|
|
Assert.notNull(candidate, "Candidate must not be null"); |
|
|
|
|
try { |
|
|
|
|
if (AopUtils.isAopProxy(candidate) && candidate instanceof Advised) { |
|
|
|
|
Object target = ((Advised) candidate).getTargetSource().getTarget(); |
|
|
|
|
if (target != null) { |
|
|
|
|
return (T) getUltimateTargetObject(target); |
|
|
|
|
return (T) getTargetObject(target); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|