Class SingletonAspectInstanceFactory

java.lang.Object
org.springframework.aop.aspectj.SingletonAspectInstanceFactory
All Implemented Interfaces:
Serializable, AspectInstanceFactory, org.springframework.core.Ordered
Direct Known Subclasses:
SingletonMetadataAwareAspectInstanceFactory

public class SingletonAspectInstanceFactory extends Object implements AspectInstanceFactory, Serializable
Implementation of AspectInstanceFactory that is backed by a specified singleton object, returning the same instance for every getAspectInstance() call.
Since:
2.0
Author:
Rod Johnson, Juergen Hoeller
See Also:
  • Field Summary

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SingletonAspectInstanceFactory for the given aspect instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Expose the aspect class loader that this factory uses.
    final Object
    Create an instance of this factory's aspect.
    int
    Determine the order for this factory's aspect instance, either an instance-specific order expressed through implementing the Ordered interface, or a fallback order.
    protected int
    getOrderForAspectClass(Class<?> aspectClass)
    Determine a fallback order for the case that the aspect instance does not express an instance-specific order through implementing the Ordered interface.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SingletonAspectInstanceFactory

      public SingletonAspectInstanceFactory(Object aspectInstance)
      Create a new SingletonAspectInstanceFactory for the given aspect instance.
      Parameters:
      aspectInstance - the singleton aspect instance
  • Method Details

    • getAspectInstance

      public final Object getAspectInstance()
      Description copied from interface: AspectInstanceFactory
      Create an instance of this factory's aspect.
      Specified by:
      getAspectInstance in interface AspectInstanceFactory
      Returns:
      the aspect instance (never null)
    • getAspectClassLoader

      @Nullable public ClassLoader getAspectClassLoader()
      Description copied from interface: AspectInstanceFactory
      Expose the aspect class loader that this factory uses.
      Specified by:
      getAspectClassLoader in interface AspectInstanceFactory
      Returns:
      the aspect class loader (or null for the bootstrap loader)
      See Also:
      • ClassUtils.getDefaultClassLoader()
    • getOrder

      public int getOrder()
      Determine the order for this factory's aspect instance, either an instance-specific order expressed through implementing the Ordered interface, or a fallback order.
      Specified by:
      getOrder in interface org.springframework.core.Ordered
      See Also:
    • getOrderForAspectClass

      protected int getOrderForAspectClass(Class<?> aspectClass)
      Determine a fallback order for the case that the aspect instance does not express an instance-specific order through implementing the Ordered interface.

      The default implementation simply returns Ordered.LOWEST_PRECEDENCE.

      Parameters:
      aspectClass - the aspect class