Aspect Ordering & Precedence Rules ​
Ordering Rules ​
Aspects execute in ascending order -
AspectExpansionProcessorsorts applicable aspects withComparator.comparingInt(PipelineAspectModel::order)and appends synthetic steps in that sorted order.Lower order executes earlier - For both
BEFORE_STEPandAFTER_STEP, lower order values are emitted earlier than higher order values.Same position chaining - If multiple aspects target the same position,
BEFORE_STEPaspects execute before the step in ascendingorder, andAFTER_STEPaspects execute after the step in ascendingorder. This follows theAspectExpansionProcessorsort-and-append logic directly.Default order is 0 - If no order is specified, aspects default to order 0.
Tie-breaking - When multiple aspects share the same order and position, execution order is deterministic but unspecified; implementations MUST preserve declaration order.
Order is signed - Order is a signed integer. Negative values are allowed and execute before zero-valued aspects.
Position precedence - BEFORE_STEP aspects always execute before the step, and AFTER_STEP aspects always execute after the step, regardless of order value.
Example ​
Consider these aspects applied to a single step:
- Aspect A: position=BEFORE_STEP, order=10
- Aspect B: position=BEFORE_STEP, order=5
- Aspect C: position=AFTER_STEP, order=0
- Aspect D: position=AFTER_STEP, order=1
The execution order would be:
- Aspect B executes (BEFORE_STEP, order=5)
- Aspect A executes (BEFORE_STEP, order=10)
- Actual step executes
- Aspect C executes (AFTER_STEP, order=0)
- Aspect D executes (AFTER_STEP, order=1)
This creates the following logical pipeline:
Input -> Aspect B -> Aspect A -> Step -> Aspect C -> Aspect D -> Output