Skip to content

Commit

Permalink
[JENKINS-52189] FlowExecutionListener.onCreated
Browse files Browse the repository at this point in the history
This method is called after the FlowExecution has been created, but before it
is started. This allows to customize the FlowExecution earlier, especially a
GraphListener can be added that also receives the FlowStartNode.
  • Loading branch information
t-8ch committed Jun 19, 2019
1 parent c713d2c commit 721df0a
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
*/
public abstract class FlowExecutionListener implements ExtensionPoint {

/**
* Called when a {@link FlowExecution} has been created, but before it starts running.
*
* The {@link FlowExecution} will already have been added to the {@link FlowExecutionList} by this point.
* Methods relating to in-progress execution state such as {@link FlowExecution#getCurrentHeads}
* will not work as intended and should not be used.
*
* @param execution The {@link FlowExecution} that has been created.
*/
public void onCreated(@Nonnull FlowExecution execution) {
}

/**
* Called when a {@link FlowExecution} has started running.
*
Expand Down Expand Up @@ -46,6 +58,15 @@ public void onResumed(@Nonnull FlowExecution execution) {
public void onCompleted(@Nonnull FlowExecution execution) {
}

/**
* Fires the {@link #onCreated(FlowExecution)} event.
*/
public static void fireCreated(@Nonnull FlowExecution execution) {
for (FlowExecutionListener listener : ExtensionList.lookup(FlowExecutionListener.class)) {
listener.onCreated(execution);
}
}

/**
* Fires the {@link #onRunning(FlowExecution)} event.
*/
Expand Down

0 comments on commit 721df0a

Please sign in to comment.