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
  • 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 interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • createProjectionInformation

      protected ProjectionInformation createProjectionInformation(Class<?> projectionType)
      Creates a fresh, cacheable ProjectionInformation 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 with Value annotations and caches the result. Will create a SpelEvaluatingMethodInterceptor if an annotation was found or return the delegate as is if not.
      Parameters:
      interceptor - the root MethodInterceptor.
      source - The backing source object.
      projectionType - the proxy target type.
      Returns:
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • registerMethodInvokerFactory

      public void registerMethodInvokerFactory(MethodInterceptorFactory factory)
      Registers the given MethodInterceptorFactory 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

      public <T> T createProjection(Class<T> projectionType, Object source)
      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 interface ProjectionFactory
      Parameters:
      projectionType - the type to create, must not be null.
      source - the object to create a projection for, must not be null.
      Returns:
    • createProjection

      public <T> T createProjection(Class<T> projectionType)
      Description copied from interface: ProjectionFactory
      Creates a projection instance for the given type.
      Specified by:
      createProjection in interface ProjectionFactory
      Parameters:
      projectionType - the type to create, must not be null.
      Returns:
    • getProjectionInformation

      public final ProjectionInformation getProjectionInformation(Class<?> projectionType)
      Description copied from interface: ProjectionFactory
      Returns the ProjectionInformation for the given projection type.
      Specified by:
      getProjectionInformation in interface ProjectionFactory
      Parameters:
      projectionType - must not be null.
      Returns: