@Test public void testIsMultipleProxy() { Bmw bmw = new Bmw(); ProxyFactory proxyFactory1 = new ProxyFactory(); TargetSource targetSource1 = new SingletonTargetSource(bmw); proxyFactory1.setTargetSource(targetSource1); Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory1.addAdvisors(advisors); Object object = proxyFactory1.getProxy(); ProxyFactory proxyFactory = new ProxyFactory(); TargetSource targetSource = new SingletonTargetSource(object); proxyFactory.setTargetSource(targetSource); Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(bmw.getClass()); for (Class<?> targetInterface : targetInterfaces) { proxyFactory.addInterface(targetInterface); } advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Car proxy = (Car) proxyFactory.getProxy(); assertTrue(SpringProxyUtils.isMultipleProxy(proxy)); SpringProxyUtils.getRealTarget(proxy); }
public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } } }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } }  }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } }  static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } }  static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy);  }