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
Modifier and TypeClassDescriptionprotected static class
-
Constructor Summary
-
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 org.aopalliance.intercept.MethodInterceptor
postProcessAccessorInterceptor
(org.aopalliance.intercept.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
(org.springframework.beans.factory.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()
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
-
createProjectionInformation
Creates a fresh, cacheableProjectionInformation
instance 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 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 interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
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:
-