diff --git a/src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java b/src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java index 975ac66ff..5659677c3 100644 --- a/src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java +++ b/src/main/java/org/springframework/data/projection/ProxyProjectionFactory.java @@ -134,6 +134,20 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware return projectionInformationCache.computeIfAbsent(projectionType, this::createProjectionInformation); } + /** + * Post-process the given {@link MethodInterceptor} for the given source instance and projection type. Default + * implementation will simply return the given interceptor. + * + * @param interceptor will never be {@literal null}. + * @param source will never be {@literal null}. + * @param projectionType will never be {@literal null}. + * @return + */ + protected MethodInterceptor postProcessAccessorInterceptor(MethodInterceptor interceptor, Object source, + Class projectionType) { + return interceptor; + } + /** * Creates a fresh, cacheable {@link ProjectionInformation} instance for the given projection type. * @@ -178,20 +192,6 @@ class ProxyProjectionFactory implements ProjectionFactory, BeanClassLoaderAware throw new IllegalStateException("No MethodInterceptorFactory found for type ".concat(source.getClass().getName())); } - /** - * Post-process the given {@link MethodInterceptor} for the given source instance and projection type. Default - * implementation will simply return the given interceptor. - * - * @param interceptor will never be {@literal null}. - * @param source will never be {@literal null}. - * @param projectionType will never be {@literal null}. - * @return - */ - protected MethodInterceptor postProcessAccessorInterceptor(MethodInterceptor interceptor, Object source, - Class projectionType) { - return interceptor; - } - /** * Custom {@link MethodInterceptor} to expose the proxy target class even if we set * {@link ProxyFactory#setOpaque(boolean)} to true to prevent properties on {@link Advised} to be rendered. diff --git a/src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java b/src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java index 8a28c184a..fa58dcefd 100644 --- a/src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java +++ b/src/main/java/org/springframework/data/projection/SpelAwareProxyProjectionFactory.java @@ -56,24 +56,6 @@ public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory impl this.beanFactory = beanFactory; } - /** - * Inspects the given target type for methods with {@link Value} annotations and caches the result. Will create a - * {@link SpelEvaluatingMethodInterceptor} if an annotation was found or return the delegate as is if not. - * - * @param interceptor the root {@link MethodInterceptor}. - * @param source The backing source object. - * @param projectionType the proxy target type. - * @return - */ - @Override - protected MethodInterceptor postProcessAccessorInterceptor(MethodInterceptor interceptor, Object source, - Class projectionType) { - - return typeCache.computeIfAbsent(projectionType, SpelAwareProxyProjectionFactory::hasMethodWithValueAnnotation) - ? new SpelEvaluatingMethodInterceptor(interceptor, source, beanFactory, parser, projectionType) - : interceptor; - } - /* * (non-Javadoc) * @see org.springframework.data.projection.ProxyProjectionFactory#createProjectionInformation(java.lang.Class) @@ -105,6 +87,24 @@ public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory impl }; } + /** + * Inspects the given target type for methods with {@link Value} annotations and caches the result. Will create a + * {@link SpelEvaluatingMethodInterceptor} if an annotation was found or return the delegate as is if not. + * + * @param interceptor the root {@link MethodInterceptor}. + * @param source The backing source object. + * @param projectionType the proxy target type. + * @return + */ + @Override + protected MethodInterceptor postProcessAccessorInterceptor(MethodInterceptor interceptor, Object source, + Class projectionType) { + + return typeCache.computeIfAbsent(projectionType, SpelAwareProxyProjectionFactory::hasMethodWithValueAnnotation) + ? new SpelEvaluatingMethodInterceptor(interceptor, source, beanFactory, parser, projectionType) + : interceptor; + } + /** * Returns whether the given type as a method annotated with {@link Value}. *