Object arg = args[0]; while (arg != null && proxyFactory.isProxyClass(arg.getClass())) { Invoker invoker = proxyFactory.getInvoker(arg);
final Object arg = args[0]; while (delegate != null && proxyFactory.isProxyClass(delegate.getClass())) { Invoker invoker = proxyFactory.getInvoker(delegate);
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {        final Object result;        final Object delegate = delegate();        // equals(...) and hashCode()        if (method.equals(ReflectionUtils.equals)) {            // TODO this whole section is really ugly and needs cleaning up            Object arg = args[0];            while (arg != null && proxyFactory.isProxyClass(arg.getClass())) {                Invoker invoker = proxyFactory.getInvoker(arg);                if (invoker instanceof DelegatingInvoker) {                    arg = ((DelegatingInvoker)invoker).delegate();                }            }            if (delegate == null) {                result = arg == null ? Boolean.TRUE : Boolean.FALSE;            } else {                result = delegate.equals(arg) ? Boolean.TRUE : Boolean.FALSE;            }        } else if (method.equals(ReflectionUtils.hashCode)) {            result = new Integer(hashCode());            // null delegate        } else if (delegate == null) {            result = null;            // regular method call        } else {            result = invokeOnDelegate(getMethodToInvoke(method), args);        }        return result;    }