Package io.jmix.flowui.sys.autowire
Class ReflectionCacheManager
java.lang.Object
io.jmix.flowui.sys.autowire.ReflectionCacheManager
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.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final com.google.common.cache.LoadingCache<Class<?>,ReflectionCacheManager.ComponentIntrospectionData> protected final Function<Class<?>,MethodHandles.Lookup> protected final com.google.common.cache.Cache<MethodHandle,MethodHandle> protected final com.google.common.cache.LoadingCache<Class<?>,ReflectionCacheManager.TargetIntrospectionData> 
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidClear underlying reflection caches.protected Class<?>getActualTypeArgument(Method targetTypedMethod) getAddListenerMethodsNotCached(Method[] uniqueDeclaredMethods) getAllFields(List<Class<?>> classes) protected List<ReflectionCacheManager.AutowireElement>getAnnotatedAutowireElementsNotCached(Class<?> componentClass, Method[] methods) protected List<ReflectionCacheManager.AnnotatedMethod<Install>>getAnnotatedInstallMethodsNotCached(Method[] uniqueDeclaredMethods) getAnnotatedListenerMethodsNotCached(Method[] uniqueDeclaredMethods) protected <T extends Annotation>
 List<ReflectionCacheManager.AnnotatedMethod<T>>getAnnotatedMethodsNotCached(Class<T> annotationClass, Method[] uniqueDeclaredMethods, Predicate<Method> filter) protected List<ReflectionCacheManager.AnnotatedMethod<Subscribe>>getAnnotatedSubscribeMethodsNotCached(Method[] uniqueDeclaredMethods) protected List<ReflectionCacheManager.AnnotatedMethod<Supply>>getAnnotatedSupplyMethodsNotCached(Method[] uniqueDeclaredMethods) getAutowireElements(Class<?> componentClass) Introspects component class if it has never introspected before and finds fields annotated byViewComponentfor autowiring.protected Class<?>getComponentEventListenerMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass) Creates or gets from cache a method factory for component event listener methods.getComponentIntrospectionDataNotCached(Class<?> viewClass) getConsumerMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass) Creates or gets from cache a method factory for consumer methods.getEventListenerMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated byEventListenerfor autowiring.getInstallMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated byInstallfor autowiring.protected Map<String,MethodHandle> getInstallTargetMethodsNotCached(Method[] uniqueDeclaredMethods) getSubscribeMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated bySubscribefor autowiring.getSupplyMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated bySupplyfor autowiring.getSupplyTargetMethodsNotCached(Method[] uniqueDeclaredMethods) getTargetAddListenerMethod(Class<?> targetClass, Class<?> eventType, 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.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.getTargetIntrospectionDataNotCached(Class<?> targetClass) 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.getValueChangeEventMethodFactory(Class<?> ownerClass, ReflectionCacheManager.AnnotatedMethod<Subscribe> annotatedMethod, Class<?> eventClass) Creates or gets from cache a method factory for value change event methods.
- 
Field Details- 
componentIntrospectionCacheprotected final com.google.common.cache.LoadingCache<Class<?>,ReflectionCacheManager.ComponentIntrospectionData> componentIntrospectionCache
- 
targetIntrospectionCacheprotected final com.google.common.cache.LoadingCache<Class<?>,ReflectionCacheManager.TargetIntrospectionData> targetIntrospectionCache
- 
lambdaMethodsCache
- 
lambdaLookupProvider
 
- 
- 
Constructor Details- 
ReflectionCacheManagerpublic ReflectionCacheManager()
 
- 
- 
Method Details- 
getAutowireElementsIntrospects component class if it has never introspected before and finds fields annotated byViewComponentfor autowiring.- Parameters:
- componentClass- component class to introspect
- Returns:
- list of ReflectionCacheManager.AutowireElement
 
- 
getSubscribeMethodspublic List<ReflectionCacheManager.AnnotatedMethod<Subscribe>> getSubscribeMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated bySubscribefor autowiring.- Parameters:
- componentClass- component class to introspect
- Returns:
- list of ReflectionCacheManager.AnnotatedMethod
 
- 
getInstallMethodspublic List<ReflectionCacheManager.AnnotatedMethod<Install>> getInstallMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated byInstallfor autowiring.- Parameters:
- componentClass- composite class to introspect
- Returns:
- list of ReflectionCacheManager.AnnotatedMethod
 
- 
getSupplyMethodspublic List<ReflectionCacheManager.AnnotatedMethod<Supply>> getSupplyMethods(Class<?> componentClass) Introspects component class if it has never introspected before and finds methods annotated bySupplyfor autowiring.- Parameters:
- componentClass- composite class to introspect
- Returns:
- list of ReflectionCacheManager.AnnotatedMethod
 
- 
getEventListenerMethodsIntrospects component class if it has never introspected before and finds methods annotated byEventListenerfor 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 MethodHandleornullif the method is not found
 
- 
getTargetInstallMethodIntrospects 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 MethodHandleornullif 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 MethodHandleornullif the method is not found
 
- 
getConsumerMethodFactorypublic 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
 
- 
getValueChangeEventMethodFactorypublic 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
 
- 
getComponentEventListenerMethodFactorypublic 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
 
- 
clearCachepublic void clearCache()Clear underlying reflection caches.
- 
getComponentIntrospectionDataNotCachedprotected ReflectionCacheManager.ComponentIntrospectionData getComponentIntrospectionDataNotCached(Class<?> viewClass) 
- 
getTargetIntrospectionDataNotCachedprotected ReflectionCacheManager.TargetIntrospectionData getTargetIntrospectionDataNotCached(Class<?> targetClass) 
- 
getAnnotatedAutowireElementsNotCachedprotected List<ReflectionCacheManager.AutowireElement> getAnnotatedAutowireElementsNotCached(Class<?> componentClass, Method[] methods) 
- 
getAnnotatedSubscribeMethodsNotCachedprotected List<ReflectionCacheManager.AnnotatedMethod<Subscribe>> getAnnotatedSubscribeMethodsNotCached(Method[] uniqueDeclaredMethods) 
- 
getAnnotatedInstallMethodsNotCachedprotected List<ReflectionCacheManager.AnnotatedMethod<Install>> getAnnotatedInstallMethodsNotCached(Method[] uniqueDeclaredMethods) 
- 
getAnnotatedSupplyMethodsNotCachedprotected List<ReflectionCacheManager.AnnotatedMethod<Supply>> getAnnotatedSupplyMethodsNotCached(Method[] uniqueDeclaredMethods) 
- 
getAnnotatedListenerMethodsNotCached
- 
getAnnotatedMethodsNotCachedprotected <T extends Annotation> List<ReflectionCacheManager.AnnotatedMethod<T>> getAnnotatedMethodsNotCached(Class<T> annotationClass, Method[] uniqueDeclaredMethods, Predicate<Method> filter) 
- 
getAddListenerMethodsNotCachedprotected Map<ReflectionCacheManager.SubscribeMethodSignature,MethodHandle> getAddListenerMethodsNotCached(Method[] uniqueDeclaredMethods) 
- 
getInstallTargetMethodsNotCached
- 
getSupplyTargetMethodsNotCachedprotected Map<ReflectionCacheManager.SupplyMethodSignature,MethodHandle> getSupplyTargetMethodsNotCached(Method[] uniqueDeclaredMethods) 
- 
getAutowiringAnnotationClass
- 
getAllFields
- 
getActualTypeArgument
 
-