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 Constants
    Enum Constant
    Description
    总是新建:没有则新建,有则暂时挂起父级业务并新建 —— 记录的最全 (记录所有业务记录,包括触发上级业务时的子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,也要记录查询业务,则查询这个业务就是必定新建。
    必须要有:有则使用,没有则报错 说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用。 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中可能需要记录部分操作详情,且这个扣库存不可单独使用,那扣库存的流程所在方法就可以是一个
    不需要:如果有则使用,没有不报错【一般不推荐已存在则复用,容易导致污染上级业务记录】 (说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用) 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中选择性记录部分操作详情,且这个扣库存可以单独使用,那扣库存的流程所在方法就可以是一个
    有则忽略:只保留外层业务记录 —— 记录最少,只记录触发点 (只记录外层业务记录,不记录子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,不记录查询业务,则查询这个业务就是有也不使用。
    取 DEFAULT 行为:不会直接应用,用户可以通过调用 setDefault(org.shoulder.log.operation.context.OperationContextStrategy) 方法改变默认业务传播行为
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    默认行为

    Fields inherited from interface org.shoulder.log.operation.context.OperationContextStrategy

    COPY, CREATE_NEW, IGNORE, REUSE, THROW_EX
  • Method Summary

    Modifier and Type
    Method
    Description
     
    当前线程有操作日志上下文信息时策略
    当前线程没有操作日志上下文信息时策略
    static void
     
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • USE_DEFAULT

      public static final OperationContextStrategyEnum USE_DEFAULT
      取 DEFAULT 行为:不会直接应用,用户可以通过调用 setDefault(org.shoulder.log.operation.context.OperationContextStrategy) 方法改变默认业务传播行为
      See Also:
    • ALWAYS_NEW

      public static final OperationContextStrategyEnum ALWAYS_NEW
      总是新建:没有则新建,有则暂时挂起父级业务并新建 —— 记录的最全 (记录所有业务记录,包括触发上级业务时的子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,也要记录查询业务,则查询这个业务就是必定新建。
    • NEW_OR_IGNORE

      public static final OperationContextStrategyEnum NEW_OR_IGNORE
      有则忽略:只保留外层业务记录 —— 记录最少,只记录触发点 (只记录外层业务记录,不记录子业务) 场景:修改用户信息时,先将用户查出,再做更新。若更新时,不记录查询业务,则查询这个业务就是有也不使用。
    • IGNORE_OR_REUSE

      public static final OperationContextStrategyEnum IGNORE_OR_REUSE
      不需要:如果有则使用,没有不报错【一般不推荐已存在则复用,容易导致污染上级业务记录】 (说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用) 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中选择性记录部分操作详情,且这个扣库存可以单独使用,那扣库存的流程所在方法就可以是一个
    • EX_OR_REUSE

      public static final OperationContextStrategyEnum EX_OR_REUSE
      必须要有:有则使用,没有则报错 说明这是一个业务子流程方法,且该方法只能由加了业务日志注解的方法调用。 场景:下单业务,扣钱、扣库存、创建订单中,扣库存的方法中可能需要记录部分操作详情,且这个扣库存不可单独使用,那扣库存的流程所在方法就可以是一个
  • Field Details

  • Method Details

    • values

      public static OperationContextStrategyEnum[] 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

      public static OperationContextStrategyEnum valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getDefault

      public static OperationContextStrategy getDefault()
    • setDefault

      public static void setDefault(OperationContextStrategy defaultStrategy)
    • onMissingContext

      @Nonnull public OpLogContext onMissingContext()
      Description copied from interface: OperationContextStrategy
      当前线程没有操作日志上下文信息时策略
      Specified by:
      onMissingContext in interface OperationContextStrategy
      Returns:
      返回的日志上下文
    • onExistContext

      @Nonnull public OpLogContext onExistContext(OpLogContext existed)
      Description copied from interface: OperationContextStrategy
      当前线程有操作日志上下文信息时策略
      Specified by:
      onExistContext in interface OperationContextStrategy
      Parameters:
      existed - 当前线程中的日志上下文
      Returns:
      返回的日志上下文