Class ReflectionCacheManager

java.lang.Object
io.jmix.flowui.sys.autowire.ReflectionCacheManager

@Component("flowui_ReflectionCacheManager") public class ReflectionCacheManager extends Object
Loads and caches data for a fields and methods that are used for autowiring.

Introspects the passed component for methods and fields that are annotated with UI system annotations. Also analyzes target classes for injection, collecting and caching data for methods-candidates for autowiring.

  • Field Details

  • Constructor Details

    • ReflectionCacheManager

      public ReflectionCacheManager()
  • Method Details

    • getAutowireElements

      public List<ReflectionCacheManager.AutowireElement> getAutowireElements(Class<?> componentClass)
      Introspects component class if it has never introspected before and finds fields annotated by ViewComponent for autowiring.
      Parameters:
      componentClass - component class to introspect
      Returns:
      list of ReflectionCacheManager.AutowireElement
    • getSubscribeMethods

      public List<ReflectionCacheManager.AnnotatedMethod<Subscribe>> getSubscribeMethods(Class<?> componentClass)
      Introspects component class if it has never introspected before and finds methods annotated by Subscribe for autowiring.
      Parameters:
      componentClass - component class to introspect
      Returns:
      list of ReflectionCacheManager.AnnotatedMethod
    • getInstallMethods

      public List<ReflectionCacheManager.AnnotatedMethod<Install>> getInstallMethods(Class<?> componentClass)
      Introspects component class if it has never introspected before and finds methods annotated by Install for autowiring.
      Parameters:
      componentClass - composite class to introspect
      Returns:
      list of ReflectionCacheManager.AnnotatedMethod
    • getSupplyMethods

      public List<ReflectionCacheManager.AnnotatedMethod<Supply>> getSupplyMethods(Class<?> componentClass)
      Introspects component class if it has never introspected before and finds methods annotated by Supply for autowiring.
      Parameters:
      componentClass - composite class to introspect
      Returns:
      list of ReflectionCacheManager.AnnotatedMethod
    • getEventListenerMethods

      public List<Method> getEventListenerMethods(Class<?> componentClass)
      Introspects component class if it has never introspected before and finds methods annotated by EventListener for autowiring.
      Parameters:
      componentClass - composite class to introspect
      Returns:
      list of Method
    • getTargetAddListenerMethod

      @Nullable public MethodHandle getTargetAddListenerMethod(Class<?> targetClass, Class<?> eventType, @Nullable String methodName)
      Introspects target class if it has never introspected before and finds method suitable for adding an event handler of a specific type for autowiring.
      Parameters:
      targetClass - class to search for method
      eventType - type of the target event parameter
      methodName - name of the target method
      Returns:
      the found MethodHandle or null if the method is not found
    • getTargetInstallMethod

      @Nullable public MethodHandle getTargetInstallMethod(Class<?> targetClass, String methodName)
      Introspects target class if it has never introspected before and finds method with passed name which suitable for setting a handler for autowiring.
      Parameters:
      targetClass - class to search for method
      methodName - name of the method
      Returns:
      the found MethodHandle or null if the method is not found
    • getTargetSupplyMethod

      @Nullable public MethodHandle getTargetSupplyMethod(Class<?> targetClass, String methodName, Class<?> parameterType)
      Introspects target class if it has never introspected before and finds method with passed name and parameter type which suitable for setting a handler for autowiring.
      Parameters:
      targetClass - class to search for method
      methodName - name of the method
      parameterType - parameter type of the parameter
      Returns:
      the found MethodHandle or null if the method is not found
    • getConsumerMethodFactory

      public MethodHandle getConsumerMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass)
      Creates or gets from cache a method factory for consumer methods.
      Parameters:
      ownerClass - owner class for target consumer
      annotatedMethod - annotated method
      eventClass - event class
      Returns:
      a factory to create consumer methods
    • getValueChangeEventMethodFactory

      public MethodHandle getValueChangeEventMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass)
      Creates or gets from cache a method factory for value change event methods.
      Parameters:
      ownerClass - owner class for target value change event method handle
      annotatedMethod - annotated method
      eventClass - event class
      Returns:
      a factory to create value change event method handle
    • getComponentEventListenerMethodFactory

      public MethodHandle getComponentEventListenerMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass)
      Creates or gets from cache a method factory for component event listener methods.
      Parameters:
      ownerClass - owner class for target component event listener method handle
      annotatedMethod - annotated method
      eventClass - event class
      Returns:
      a factory to create component event listener method handle
    • getEventListenerMethodFactory

      public MethodHandle getEventListenerMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, String interfaceMethodName, Class<?> listenerClass, Class<?> eventClass)
      Creates or gets from cache a method factory for any event listener methods.
      Parameters:
      ownerClass - owner class for target event listener method handle
      annotatedMethod - annotated method
      interfaceMethodName - name of the target interface method
      listenerClass - listener class
      eventClass - event class
      Returns:
      a factory to create event listener method handle
    • clearCache

      public void clearCache()
      Clear underlying reflection caches.
    • getComponentIntrospectionDataNotCached

      protected ReflectionCacheManager.ComponentIntrospectionData getComponentIntrospectionDataNotCached(Class<?> viewClass)
    • getTargetIntrospectionDataNotCached

      protected ReflectionCacheManager.TargetIntrospectionData getTargetIntrospectionDataNotCached(Class<?> targetClass)
    • getAnnotatedAutowireElementsNotCached

      protected List<ReflectionCacheManager.AutowireElement> getAnnotatedAutowireElementsNotCached(Class<?> componentClass, Method[] methods)
    • getAnnotatedSubscribeMethodsNotCached

      protected List<ReflectionCacheManager.AnnotatedMethod<Subscribe>> getAnnotatedSubscribeMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getAnnotatedInstallMethodsNotCached

      protected List<ReflectionCacheManager.AnnotatedMethod<Install>> getAnnotatedInstallMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getAnnotatedSupplyMethodsNotCached

      protected List<ReflectionCacheManager.AnnotatedMethod<Supply>> getAnnotatedSupplyMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getAnnotatedListenerMethodsNotCached

      protected List<Method> getAnnotatedListenerMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getAnnotatedMethodsNotCached

      protected <T extends Annotation> List<ReflectionCacheManager.AnnotatedMethod<T>> getAnnotatedMethodsNotCached(Class<T> annotationClass, Method[] uniqueDeclaredMethods, Predicate<Method> filter)
    • getAddListenerMethodsNotCached

      protected Map<ReflectionCacheManager.SubscribeMethodSignature,MethodHandle> getAddListenerMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getInstallTargetMethodsNotCached

      protected Map<String,MethodHandle> getInstallTargetMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getSupplyTargetMethodsNotCached

      protected Map<ReflectionCacheManager.SupplyMethodSignature,MethodHandle> getSupplyTargetMethodsNotCached(Method[] uniqueDeclaredMethods)
    • getAutowiringAnnotationClass

      @Nullable protected Class<?> getAutowiringAnnotationClass(AnnotatedElement element)
    • getAllFields

      protected List<Field> getAllFields(List<Class<?>> classes)
    • getActualTypeArgument

      @Nullable protected Class<?> getActualTypeArgument(Method targetTypedMethod)