Class SpelAwareProxyProjectionFactory
java.lang.Object
org.springframework.data.projection.SpelAwareProxyProjectionFactory
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,ProjectionFactory
public class SpelAwareProxyProjectionFactory
extends Object
implements org.springframework.beans.factory.BeanFactoryAware
A
ProxyProjectionFactory that adds support to use Value-annotated methods on a projection interface
to evaluate the contained SpEL expression to define the outcome of the method call.- Since:
- 1.10
- Author:
- Oliver Gierke, Thomas Darimont, Mark Paluch, Jens Schauder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TcreateProjection(Class<T> projectionType) Creates a projection instance for the given type.<T> TcreateProjection(Class<T> projectionType, Object source) Creates a projection of the given type for the given source object.protected ProjectionInformationcreateProjectionInformation(Class<?> projectionType) Creates a fresh, cacheableProjectionInformationinstance for the given projection type.final ProjectionInformationgetProjectionInformation(Class<?> projectionType) Returns theProjectionInformationfor the given projection type.protected org.aopalliance.intercept.MethodInterceptorpostProcessAccessorInterceptor(org.aopalliance.intercept.MethodInterceptor interceptor, Object source, Class<?> projectionType) Inspects the given target type for methods withValueannotations and caches the result.voidRegisters the givenMethodInterceptorFactoryto be used with the factory.voidsetBeanClassLoader(ClassLoader classLoader) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.projection.ProjectionFactory
createNullableProjection
-
Constructor Details
-
SpelAwareProxyProjectionFactory
public SpelAwareProxyProjectionFactory()
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
createProjectionInformation
Creates a fresh, cacheableProjectionInformationinstance for the given projection type.- Parameters:
projectionType- must not be null.- Returns:
-
postProcessAccessorInterceptor
protected org.aopalliance.intercept.MethodInterceptor postProcessAccessorInterceptor(org.aopalliance.intercept.MethodInterceptor interceptor, Object source, Class<?> projectionType) Inspects the given target type for methods withValueannotations and caches the result. Will create aSpelEvaluatingMethodInterceptorif an annotation was found or return the delegate as is if not.- Parameters:
interceptor- the rootMethodInterceptor.source- The backing source object.projectionType- the proxy target type.- Returns:
-
setBeanClassLoader
- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
registerMethodInvokerFactory
Registers the givenMethodInterceptorFactoryto be used with the factory. Factories registered later enjoy precedence over previously registered ones.- Parameters:
factory- must not be null.- Since:
- 1.13
-
createProjection
Description copied from interface:ProjectionFactoryCreates a projection of the given type for the given source object. The individual mapping strategy is defined by the implementations.- Specified by:
createProjectionin interfaceProjectionFactory- Parameters:
projectionType- the type to create, must not be null.source- the object to create a projection for, must not be null.- Returns:
-
createProjection
Description copied from interface:ProjectionFactoryCreates a projection instance for the given type.- Specified by:
createProjectionin interfaceProjectionFactory- Parameters:
projectionType- the type to create, must not be null.- Returns:
-
getProjectionInformation
Description copied from interface:ProjectionFactoryReturns theProjectionInformationfor the given projection type.- Specified by:
getProjectionInformationin interfaceProjectionFactory- Parameters:
projectionType- must not be null.- Returns:
-