public class TypeHierarchyBeanOperationParser extends Object implements BeanOperationParser
操作配置解析器的通用实现。
工作机制
在解析配置时,解析器将创建一个根配置对象作为此次执行的上下文,
然后依次调用所有注册的 注解处理器,
将配置信息收集到上下文中的配置对象中。
解析完成后,将缓存与AnnotatedElement对应的BeanOperations实例,
下次访问时将优先使用缓存。
扫描范围
在解析元素时,如果是:
操作配置的顺序
解析器获取的操作顺序遵循:
注解处理器的调用顺序;执行器保证。
General implementation of BeanOperationParser.
Working Mechanism
When parsing the configuration, the parser will create a root BeanOperations
as the context for this execution, Then successively call all registered OperationAnnotationHandler
to collect the configuration information into the BeanOperations in context.
After the parsing is completed, the BeanOperations instance
corresponding to the AnnotatedElement will be cached,
and the cache will be used preferentially for the next access.
Scanning Range
When parsing element, if it is a:
Class: it will check all parent classes and interfaces in its hierarchy;Method: it will check for methods with the same method signature in all parent classes and interfaces in its hierarchy;Order of Operation Configuration
The sequence of operations obtained through the parser follows:
OperationAnnotationHandler;OperationAnnotationHandler;BeanOperationExecutor.OperationAnnotationHandler| 限定符和类型 | 字段和说明 |
|---|---|
protected Map<AnnotatedElement,BeanOperations> |
currentlyInParsing
temp cache for operations of element that currently in parsing
|
protected boolean |
enableHierarchyCache
Whether to cache hierarchy operation info of an element.
|
protected List<OperationAnnotationHandler> |
operationAnnotationHandlers
registered operation annotation resolvers.
|
protected Map<AnnotatedElement,BeanOperations> |
resolvedElements
cache for operations of a resolved element.
|
protected Map<AnnotatedElement,BeanOperations> |
resolvedHierarchyElements
temp cache for operations of a resolved element where in type hierarchy.
|
| 构造器和说明 |
|---|
TypeHierarchyBeanOperationParser() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addOperationAnnotationHandler(OperationAnnotationHandler handler)
Add bean operations resolvers.
|
protected BeanOperations |
createBeanOperations(AnnotatedElement element,
boolean root)
Create
BeanOperations instance. |
protected BeanOperations |
doResolveToOperations(AnnotatedElement source) |
Collection<OperationAnnotationHandler> |
getOperationAnnotationHandlers()
Get all operation annotation handlers.
|
protected void |
mergeBeanOperationsToRootBeanOperations(BeanOperations root,
Collection<BeanOperations> childOperations)
Merge each child
BeanOperations to root BeanOperations. |
@NonNull BeanOperations |
parse(AnnotatedElement element)
Parse the class and class attribute information,
and generate the corresponding
BeanOperations instance. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetNameprotected final Map<AnnotatedElement,BeanOperations> currentlyInParsing
protected final Map<AnnotatedElement,BeanOperations> resolvedHierarchyElements
protected final Map<AnnotatedElement,BeanOperations> resolvedElements
protected final List<OperationAnnotationHandler> operationAnnotationHandlers
protected boolean enableHierarchyCache
public void addOperationAnnotationHandler(OperationAnnotationHandler handler)
handler - handlerpublic Collection<OperationAnnotationHandler> getOperationAnnotationHandlers()
@NonNull public @NonNull BeanOperations parse(AnnotatedElement element) throws OperationParseException
Parse the class and class attribute information,
and generate the corresponding BeanOperations instance.
If there is a cache, it will be obtained from the cache first.
NOTE:The BeanOperations obtained may still be being parsed.
Please confirm whether it is ready through BeanOperations.isActive().
parse 在接口中 BeanOperationParserelement - element to parseBeanOperationsOperationParseException - thrown when configuration resolution exceptionprotected void mergeBeanOperationsToRootBeanOperations(BeanOperations root, Collection<BeanOperations> childOperations)
BeanOperations to root BeanOperations.root - rootchildOperations - child operationsprotected BeanOperations createBeanOperations(AnnotatedElement element, boolean root)
BeanOperations instance.element - elementroot - whether the element is rootBeanOperationsprotected BeanOperations doResolveToOperations(AnnotatedElement source)
Copyright © 2024. All rights reserved.