Enum OperationContextStrategyEnum
java.lang.Object
java.lang.Enum<OperationContextStrategyEnum>
org.shoulder.log.operation.context.OperationContextStrategyEnum
- All Implemented Interfaces:
Serializable,Comparable<OperationContextStrategyEnum>,java.lang.constant.Constable,OperationContextStrategy
public enum OperationContextStrategyEnum
extends Enum<OperationContextStrategyEnum>
implements OperationContextStrategy
shoulder 定义的业务,传播。
变量命名:A_OR_B (if exist then A else then B)
推荐使用 NEW_OR_IGNORE、ALWAYS_NEW
- Author:
- lym
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription总是新建:没有则新建,有则暂时挂起父级业务并新建 —— 记录的最全 (记录所有业务记录,包括触发上级业务时的子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,也要记录查询业务,则查询这个业务就是必定新建。必须要有:有则使用,没有则报错 说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用。 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中可能需要记录部分操作详情,且这个扣库存不可单独使用,那扣库存的流程所在方法就可以是一个不需要:如果有则使用,没有不报错【一般不推荐已存在则复用,容易导致污染上级业务记录】 (说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用) 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中选择性记录部分操作详情,且这个扣库存可以单独使用,那扣库存的流程所在方法就可以是一个有则忽略:只保留外层业务记录 —— 记录最少,只记录触发点 (只记录外层业务记录,不记录子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,不记录查询业务,则查询这个业务就是有也不使用。取 DEFAULT 行为:不会直接应用,用户可以通过调用setDefault(org.shoulder.log.operation.context.OperationContextStrategy)方法改变默认业务传播行为 -
Field Summary
FieldsFields inherited from interface org.shoulder.log.operation.context.OperationContextStrategy
COPY, CREATE_NEW, IGNORE, REUSE, THROW_EX -
Method Summary
Modifier and TypeMethodDescriptionstatic OperationContextStrategyonExistContext(OpLogContext existed) 当前线程有操作日志上下文信息时策略当前线程没有操作日志上下文信息时策略static voidsetDefault(OperationContextStrategy defaultStrategy) static OperationContextStrategyEnumReturns the enum constant of this type with the specified name.static OperationContextStrategyEnum[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
USE_DEFAULT
取 DEFAULT 行为:不会直接应用,用户可以通过调用setDefault(org.shoulder.log.operation.context.OperationContextStrategy)方法改变默认业务传播行为- See Also:
-
ALWAYS_NEW
总是新建:没有则新建,有则暂时挂起父级业务并新建 —— 记录的最全 (记录所有业务记录,包括触发上级业务时的子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,也要记录查询业务,则查询这个业务就是必定新建。 -
NEW_OR_IGNORE
有则忽略:只保留外层业务记录 —— 记录最少,只记录触发点 (只记录外层业务记录,不记录子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,不记录查询业务,则查询这个业务就是有也不使用。 -
IGNORE_OR_REUSE
不需要:如果有则使用,没有不报错【一般不推荐已存在则复用,容易导致污染上级业务记录】 (说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用) 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中选择性记录部分操作详情,且这个扣库存可以单独使用,那扣库存的流程所在方法就可以是一个 -
EX_OR_REUSE
必须要有:有则使用,没有则报错 说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用。 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中可能需要记录部分操作详情,且这个扣库存不可单独使用,那扣库存的流程所在方法就可以是一个
-
-
Field Details
-
DEFAULT
默认行为
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getDefault
-
setDefault
-
onMissingContext
Description copied from interface:OperationContextStrategy当前线程没有操作日志上下文信息时策略- Specified by:
onMissingContextin interfaceOperationContextStrategy- Returns:
- 返回的日志上下文
-
onExistContext
Description copied from interface:OperationContextStrategy当前线程有操作日志上下文信息时策略- Specified by:
onExistContextin interfaceOperationContextStrategy- Parameters:
existed- 当前线程中的日志上下文- Returns:
- 返回的日志上下文
-