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
Modifier and TypeClassDescriptionprotected static class
-
Constructor Summary
ConstructorDescriptionCreate a newSpelAwareProxyProjectionFactory
.Create a newSpelAwareProxyProjectionFactory
for a givenExpressionParser
. -
Method Summary
Modifier and TypeMethodDescription<T> T
createProjection
(Class<T> projectionType) Creates a projection instance for the given type.<T> T
createProjection
(Class<T> projectionType, Object source) Creates a projection of the given type for the given source object.protected ProjectionInformation
createProjectionInformation
(Class<?> projectionType) Creates a fresh, cacheableProjectionInformation
instance for the given projection type.final ProjectionInformation
getProjectionInformation
(Class<?> projectionType) Returns theProjectionInformation
for the given projection type.protected MethodInterceptor
postProcessAccessorInterceptor
(MethodInterceptor interceptor, Object source, Class<?> projectionType) Inspects the given target type for methods withValue
annotations and caches the result.void
Registers the givenMethodInterceptorFactory
to be used with the factory.void
setBeanClassLoader
(ClassLoader classLoader) void
setBeanFactory
(BeanFactory beanFactory) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.projection.ProjectionFactory
createNullableProjection
-
Constructor Details
-
SpelAwareProxyProjectionFactory
public SpelAwareProxyProjectionFactory()Create a newSpelAwareProxyProjectionFactory
. -
SpelAwareProxyProjectionFactory
Create a newSpelAwareProxyProjectionFactory
for a givenExpressionParser
.- Parameters:
parser
- the parser to use.- Since:
- 3.3
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
createProjectionInformation
Creates a fresh, cacheableProjectionInformation
instance 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 withValue
annotations and caches the result. Will create aSpelEvaluatingMethodInterceptor
if 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:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
registerMethodInvokerFactory
Registers the givenMethodInterceptorFactory
to 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:ProjectionFactory
Creates a projection of the given type for the given source object. The individual mapping strategy is defined by the implementations.- Specified by:
createProjection
in 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:ProjectionFactory
Creates a projection instance for the given type.- Specified by:
createProjection
in interfaceProjectionFactory
- Parameters:
projectionType
- the type to create, must not be null.- Returns:
-
getProjectionInformation
Description copied from interface:ProjectionFactory
Returns theProjectionInformation
for the given projection type.- Specified by:
getProjectionInformation
in interfaceProjectionFactory
- Parameters:
projectionType
- must not be null.- Returns:
-