Class SpelAwareProxyProjectionFactory
java.lang.Object
org.springframework.data.projection.SpelAwareProxyProjectionFactory
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,BeanFactoryAware,ProjectionFactory
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
ConstructorsConstructorDescriptionCreate a newSpelAwareProxyProjectionFactory.Create a newSpelAwareProxyProjectionFactoryfor a givenExpressionParser. -
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 MethodInterceptorpostProcessAccessorInterceptor(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(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()Create a newSpelAwareProxyProjectionFactory. -
SpelAwareProxyProjectionFactory
Create a newSpelAwareProxyProjectionFactoryfor a givenExpressionParser.- Parameters:
parser- the parser to use.- Since:
- 3.3
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Throws:
BeansException
-
createProjectionInformation
Creates a fresh, cacheableProjectionInformationinstance for the given projection type.- Parameters:
projectionType- must not be null.- Returns:
-
postProcessAccessorInterceptor
protected MethodInterceptor postProcessAccessorInterceptor(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 interfaceBeanClassLoaderAware
-
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:
-