factory.setCallbacks(new Callback[] {NoOp.INSTANCE, new LookupOverrideMethodInterceptor(this.beanDefinition, this.owner), new ReplaceOverrideMethodInterceptor(this.beanDefinition, this.owner)});
@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; } } }
((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> { if (method.getName().equals("getObject") && args.length == 0) { return beanFactory.getBean(beanName);
((Factory) proxyInstance).setCallbacks(callbacks); return proxyInstance;
public static MethodInterceptorRdf getMethodInterceptor(Object o) { MethodInterceptorRdf result = null; if(o != null && Enhancer.isEnhanced(o.getClass())) { Factory factory = (Factory)o; Callback callback = factory.getCallback(0); result = callback != null && callback instanceof MethodInterceptorRdf ? (MethodInterceptorRdf)callback : null; } return result; }
((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> { if (method.getName().equals("getObject") && args.length == 0) { return beanFactory.getBean(beanName);
factory.setCallbacks(new Callback[] {NoOp.INSTANCE, new LookupOverrideMethodInterceptor(this.beanDefinition, this.owner), new ReplaceOverrideMethodInterceptor(this.beanDefinition, this.owner)});
public static MethodInterceptorRdf getMethodInterceptor(Object o) { MethodInterceptorRdf result = null; if(o != null && Enhancer.isEnhanced(o.getClass())) { Factory factory = (Factory)o; Callback callback = factory.getCallback(0); result = callback != null && callback instanceof MethodInterceptorRdf ? (MethodInterceptorRdf)callback : null; } return result; }
((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> { if (method.getName().equals("getObject") && args.length == 0) { return beanFactory.getBean(beanName);
((Factory) proxy).setCallbacks(new Callback[] {interceptor}); return (T) proxy;
@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; } } }
/** * 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()); }
@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 EagleTraceCglibProxy.EqualsInterceptor)) { return false; } AdvisedSupport otherAdvised = ((EagleTraceCglibProxy.EqualsInterceptor) callback).advised; return AopProxyUtils.equalsInProxy(this.advised, otherAdvised); } else { return false; } } }
((Factory) proxy).setCallbacks(new Callback[] {interceptor}); return (T) proxy;
@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; } } }
((Factory) proxy).setCallbacks(new Callback[] {interceptor}); return (T) proxy;
((Factory) proxy).setCallbacks(new Callback[] {interceptor}); return (T) proxy;
((Factory) proxy).setCallbacks(new Callback[] {interceptor}); return (T) proxy;
@SuppressWarnings("unchecked") private static <T> T getProxyWithInterceptor(Class<?> type, InvocationRecordingMethodInterceptor interceptor, ClassLoader classLoader) { if (type.isInterface()) { ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE); factory.addInterface(type); factory.addInterface(LastInvocationAware.class); factory.addAdvice(interceptor); return (T) factory.getProxy(); } Factory factory = (Factory) OBJENESIS.newInstance(getOrCreateEnhancedClass(type, classLoader)); factory.setCallbacks(new Callback[] { interceptor }); return (T) factory; }
/** * 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()); }