use of org.jenkinsci.plugins.workflow.flow.GraphListener in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method notifyListeners.
void notifyListeners(List<FlowNode> nodes, boolean synchronous) {
List<GraphListener> toRun = getListenersToRun();
if (!toRun.isEmpty()) {
Saveable s = Saveable.NOOP;
try {
Queue.Executable exec = owner.getExecutable();
if (exec instanceof Saveable) {
s = (Saveable) exec;
}
} catch (IOException x) {
LOGGER.log(Level.WARNING, "failed to notify listeners of changes to " + nodes + " in " + this, x);
}
BulkChange bc = new BulkChange(s);
try {
for (FlowNode node : nodes) {
for (GraphListener listener : toRun) {
if (listener instanceof GraphListener.Synchronous == synchronous) {
listener.onNewHead(node);
}
}
}
} finally {
if (synchronous) {
// hack to skip save—we are holding a lock
bc.abort();
} else {
try {
bc.commit();
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, x);
}
}
}
}
}
Aggregations