public abstract class AbstractBeanOperationExecutor extends Object implements BeanOperationExecutor
This class serves as a template class and provides a basic skeleton implementation
for most of the BeanOperationExecutor,
particularly shielding the complexity of parsing DisassembleOperation operations.
Once the executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method is implemented in a subclass,
it can be used as a BeanOperationExecutor.
According to the instructions specified in BeanOperations,
the following steps are performed when executing operations through the BeanOperationExecutor.execute(java.util.Collection<?>, cn.crane4j.core.parser.BeanOperations, cn.crane4j.core.executor.BeanOperationExecutor.Options) method:
DisassembleOperation operations to be executed,
recursively extract and flatten the objects that need to be processed from
the target object (if it is a collection or an array, iterate over each element);
BeanOperations,
and wrap each group into an AssembleExecution object.
executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method implemented in the subclass to
actually perform the operations within each AssembleExecution.
This class only guarantees the sequential execution of DisassembleOperation operations,
while the sequential execution of AssembleOperation operations depends on
the implementation logic of executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options).
For performance reasons, when implementing the executeOperations(java.util.List<cn.crane4j.core.executor.AssembleExecution>, cn.crane4j.core.executor.BeanOperationExecutor.Options) method,
it is recommended to minimize the number of accesses to the Container.
AsyncBeanOperationExecutor,
DisorderedBeanOperationExecutor,
OrderedBeanOperationExecutorBeanOperationExecutor.Options| 限定符和类型 | 字段和说明 |
|---|---|
boolean |
enableExecuteNotActiveOperation
Whether to enable the execution of operations that are not active.
|
long |
waitTimeoutMillisecondIfOperationNotActive
Wait time in milliseconds if the operation is not active.
|
| 构造器和说明 |
|---|
AbstractBeanOperationExecutor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected AssembleExecution |
createAssembleExecution(BeanOperations beanOperations,
AssembleOperation operation,
Collection<Object> targets,
BeanOperationExecutor.Options options)
Create a
AssembleExecution. |
void |
execute(Collection<?> targets,
BeanOperations operations,
BeanOperationExecutor.Options options)
Complete operations on all objects in
targets according to the specified BeanOperations and Options. |
protected abstract void |
executeOperations(List<AssembleExecution> executions,
BeanOperationExecutor.Options options)
Complete the assembly operation.
|
protected static void |
tryExecute(Runnable execute)
Try to execute the operation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecute, executepublic long waitTimeoutMillisecondIfOperationNotActive
Wait time in milliseconds if the operation is not active.
In normal cases, this time is unnecessary set to a large value,
because the operation is usually active when the execute(java.util.Collection<?>, cn.crane4j.core.parser.BeanOperations, cn.crane4j.core.executor.BeanOperationExecutor.Options) method is called,
Unless there is a circular dependency between the operation and the resolution of another object during the parsing process.
NOTE: This is not a good solution, so in future versions,
we will try to solve this problem in the BeanOperationParser.
public boolean enableExecuteNotActiveOperation
public void execute(Collection<?> targets, BeanOperations operations, BeanOperationExecutor.Options options)
targets according to the specified BeanOperations and Options.execute 在接口中 BeanOperationExecutortargets - targetsoperations - operations to be performedoptions - options for executionprotected AssembleExecution createAssembleExecution(BeanOperations beanOperations, AssembleOperation operation, Collection<Object> targets, BeanOperationExecutor.Options options)
AssembleExecution.beanOperations - bean operationsoperation - operationtargets - targetsoptions - options for executionAssembleExecutionprotected abstract void executeOperations(List<AssembleExecution> executions, BeanOperationExecutor.Options options) throws OperationExecuteException
Complete the assembly operation.
All operations of input parameters ensure their orderliness in the same class.
For example, if there are ordered operations a and b in A.class,
the order of a and b is still guaranteed when
the corresponding AssembleExecution is obtained.
executions - assembly operations to be completedoptions - options for executionOperationExecuteException - thrown when operation execution exceptionprotected static void tryExecute(Runnable execute)
Try to execute the operation.
If necessary, output the log when throwing an exception.
execute - executeCopyright © 2023. All rights reserved.