return ensureResolved(); return proxyToString(proxy); return proxyEquals(proxy, args[0]); return proxyHashCode(proxy); Object target = ensureResolved();
@Override public Object invoke(@Nullable MethodInvocation invocation) throws Throwable { return intercept(invocation.getThis(), invocation.getMethod(), invocation.getArguments(), null); }
/** * Will trigger the resolution if the proxy is not resolved already or return a previously resolved result. * * @return */ @Nullable private Object ensureResolved() { if (!resolved) { this.result = resolve(); this.resolved = true; } return this.result; }
return ensureResolved(); return proxyToString(proxy); return proxyEquals(proxy, args[0]); return proxyHashCode(proxy); Object target = ensureResolved();
/** * Creates a proxy for the given {@link MongoPersistentProperty} using the given {@link DbRefResolverCallback} to * eventually resolve the value of the property. * * @param property must not be {@literal null}. * @param dbref can be {@literal null}. * @param callback must not be {@literal null}. * @return */ private Object createLazyLoadingProxy(MongoPersistentProperty property, @Nullable DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler handler) { Class<?> propertyType = property.getType(); LazyLoadingInterceptor interceptor = new LazyLoadingInterceptor(property, dbref, exceptionTranslator, callback); if (!propertyType.isInterface()) { Factory factory = (Factory) objenesis.newInstance(getEnhancedTypeFor(propertyType)); factory.setCallbacks(new Callback[] { interceptor }); return handler.populateId(property, dbref, factory); } ProxyFactory proxyFactory = new ProxyFactory(); for (Class<?> type : propertyType.getInterfaces()) { proxyFactory.addInterface(type); } proxyFactory.addInterface(LazyLoadingProxy.class); proxyFactory.addInterface(propertyType); proxyFactory.addAdvice(interceptor); return handler.populateId(property, dbref, proxyFactory.getProxy()); }
/** * Performs an equality check for the given {@code proxy}. * * @param proxy * @param that * @return */ private boolean proxyEquals(@Nullable Object proxy, Object that) { if (!(that instanceof LazyLoadingProxy)) { return false; } if (that == proxy) { return true; } return proxyToString(proxy).equals(that.toString()); }
/** * Will trigger the resolution if the proxy is not resolved already or return a previously resolved result. * * @return */ @Nullable private Object ensureResolved() { if (!resolved) { this.result = resolve(); this.resolved = true; } return this.result; }
@Override public Object invoke(@Nullable MethodInvocation invocation) throws Throwable { return intercept(invocation.getThis(), invocation.getMethod(), invocation.getArguments(), null); }
/** * Returns the hashcode for the given {@code proxy}. * * @param proxy * @return */ private int proxyHashCode(@Nullable Object proxy) { return proxyToString(proxy).hashCode(); }
/** * Callback method for serialization. * * @param out * @throws IOException */ private void writeObject(ObjectOutputStream out) throws IOException { ensureResolved(); out.writeObject(this.result); }
/** * Creates a proxy for the given {@link MongoPersistentProperty} using the given {@link DbRefResolverCallback} to * eventually resolve the value of the property. * * @param property must not be {@literal null}. * @param dbref can be {@literal null}. * @param callback must not be {@literal null}. * @return */ private Object createLazyLoadingProxy(MongoPersistentProperty property, @Nullable DBRef dbref, DbRefResolverCallback callback, DbRefProxyHandler handler) { Class<?> propertyType = property.getType(); LazyLoadingInterceptor interceptor = new LazyLoadingInterceptor(property, dbref, exceptionTranslator, callback); if (!propertyType.isInterface()) { Factory factory = (Factory) objenesis.newInstance(getEnhancedTypeFor(propertyType)); factory.setCallbacks(new Callback[] { interceptor }); return handler.populateId(property, dbref, factory); } ProxyFactory proxyFactory = new ProxyFactory(); for (Class<?> type : propertyType.getInterfaces()) { proxyFactory.addInterface(type); } proxyFactory.addInterface(LazyLoadingProxy.class); proxyFactory.addInterface(propertyType); proxyFactory.addAdvice(interceptor); return handler.populateId(property, dbref, proxyFactory.getProxy()); }
/** * Performs an equality check for the given {@code proxy}. * * @param proxy * @param that * @return */ private boolean proxyEquals(@Nullable Object proxy, Object that) { if (!(that instanceof LazyLoadingProxy)) { return false; } if (that == proxy) { return true; } return proxyToString(proxy).equals(that.toString()); }
/** * Callback method for serialization. * * @param out * @throws IOException */ private void writeObject(ObjectOutputStream out) throws IOException { ensureResolved(); out.writeObject(this.result); }
/** * Returns the hashcode for the given {@code proxy}. * * @param proxy * @return */ private int proxyHashCode(@Nullable Object proxy) { return proxyToString(proxy).hashCode(); }