/** * Equality means interfaces, advisors and TargetSource are equal. * * <p>The compared object may be a JdkDynamicAopProxy instance itself or a dynamic proxy wrapping * a JdkDynamicAopProxy instance. */ public boolean equals(Object other) { if (other == this) { return true; } if (other == null) { return false; } JdkDynamicAopProxy otherProxy = null; if (other instanceof JdkDynamicAopProxy) { otherProxy = (JdkDynamicAopProxy) other; } else if (Proxy.isProxyClass(other.getClass())) { InvocationHandler ih = Proxy.getInvocationHandler(other); if (!(ih instanceof JdkDynamicAopProxy)) { return false; } otherProxy = (JdkDynamicAopProxy) ih; } else { // Not a valid comparison... return false; } // If we get here, aopr2 is the other AopProxy. return AopProxyUtils.equalsInProxy(this.advised, otherProxy.advised); }
@Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) { Object other = args[0]; if (proxy == other) { return true; } if (other instanceof Factory) { Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS); if (!(callback instanceof EqualsInterceptor)) { return false; } AdvisedSupport otherAdvised = ((EqualsInterceptor) callback).advised; return AopProxyUtils.equalsInProxy(this.advised, otherAdvised); } else { return false; } }
@Override public boolean equals(Object other) { return (this == other || (other instanceof CglibAopProxy && AopProxyUtils.equalsInProxy(this.advised, ((CglibAopProxy) other).advised))); }