Class MethodScan

java.lang.Object
com.ultikits.ultitools.aop.MethodScan

final class MethodScan extends Object
The result of one ReflectionUtil.getAllMethods(Class) hierarchy scan, together with the bean class it was scanned for.

AopProxyResolver.resolve(Class) used to hand a bare Class<?> to each of its consumers, and every one of them repeated the same reflective hierarchy walk: the unavailable- annotation locator, the intercepted-method collector, the diagnostic pass, and AopEligibility.findAopAnnotatedMethods(Class) - four scans of the same hierarchy on the startup path, for every bean of every module. This carries the scan's own result so consumers stop repeating it (D-37).

The bean class travels with the methods rather than being re-derived by each consumer, because two of AopEligibility's five rules are relative to it - a method is not intrinsically unproxyable, it is unproxyable from a particular subclass. Passing the two separately is how they would drift apart later.

Stated limitation, not papered over: this is a value object, not a capability. Nothing stops a future edit from calling ReflectionUtil.getAllMethods(Class) directly again instead of building or reusing a scan - the only guard is AopProxyResolverScanCountTest, which fails if a rescan returns. See issue #309.

Since:
6.3.0
Author:
wisdomme
  • Field Details

    • beanClass

      private final Class<?> beanClass
    • methods

      private final List<Method> methods
  • Constructor Details

  • Method Details

    • of

      static MethodScan of(Class<?> beanClass)
      Convenience factory for a caller that has not already scanned the class.

      Exists so single-class entry points that predate MethodScan - AopEligibility.findAopAnnotatedMethods(Class) among them - keep working without forcing every caller to scan for itself first. AopProxyResolver.resolve(Class) does not use this factory: it builds its one scan directly and hands the same instance to every consumer, which is the single-pass guarantee this class exists for.

      Parameters:
      beanClass - the class to scan
      Returns:
      a scan of the given class's method hierarchy
    • getBeanClass

      Class<?> getBeanClass()
      Returns:
      the class this scan was taken for
    • getMethods

      List<Method> getMethods()
      Returns:
      the scanned methods, subclass overrides first, bridge and synthetic declarations already dropped